mimetypes

Java (JVM) lookup table for standard mime types and their extensions

License

License

GroupId

GroupId

com.github.amr
ArtifactId

ArtifactId

mimetypes
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

mimetypes
Java (JVM) lookup table for standard mime types and their extensions
Project URL

Project URL

http://github.com/amr/mimetypes
Source Code Management

Source Code Management

https://github.com/amr/mimetypes.git

Download mimetypes

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.amr/mimetypes/ -->
<dependency>
    <groupId>com.github.amr</groupId>
    <artifactId>mimetypes</artifactId>
    <version>0.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.amr/mimetypes/
implementation 'com.github.amr:mimetypes:0.0.3'
// https://jarcasting.com/artifacts/com.github.amr/mimetypes/
implementation ("com.github.amr:mimetypes:0.0.3")
'com.github.amr:mimetypes:jar:0.0.3'
<dependency org="com.github.amr" name="mimetypes" rev="0.0.3">
  <artifact name="mimetypes" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.amr', module='mimetypes', version='0.0.3')
)
libraryDependencies += "com.github.amr" % "mimetypes" % "0.0.3"
[com.github.amr/mimetypes "0.0.3"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

MimeTypes

Build Status Test Coverage

Java (JVM) lookup table for standard mime types and their extensions.

API Usage

Get the extension for a mime type:

MimeTypes.getInstance().getByType("image/png").getExtension(); // returns "png"

Get all possible extensions for a mime type:

MimeTypes.getInstance().getByType("image/png").getExtensions(); // returns String[]{"png"}
MimeTypes.getInstance().getByType("text/html").getExtensions(); // returns String[]{"html", "htm"}

Get mime type for an extension:

MimeTypes.getInstance().getByExtension("png").getMimeType(); // returns "image/png"

Register a custom mimetype and query it up later:

MimeTypes.getInstance().register(new MimeType("application/vnd.awesome", new String[]{"wsm"}));
MimeTypes.getInstance().getByType("application/vnd.awesome").getExtension(); // returns "wsm"

Initialize with a custom "mime.types" definitions file:

new MimeTypes(Paths.get("/path/to/custom/mime.types"));

Alternatively:

MimeTypes.blank().load(Paths.get("/path/to/custom/mime.types"));

Build

Using maven:

mvn package

If you want the sources and javadocs too:

mvn package -P release

Maven central coordinates

New releases are submitted to central, to use:

<dependencies>
  <dependency>
    <groupId>com.github.amr</groupId>
    <artifactId>mimetypes</artifactId>
    <version>0.0.3</version>
  </dependency>
</dependencies>

Included mime types

MimeTypes.getInstance() or the empty constructor new MimeTypes() will load the included mime.types definitions, which is downloaded from:

http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types

JVM

JVM 7 or later is required.

License

Versions

Version
0.0.3
0.0.2