Skip to content
/ mimetypes Public

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

Notifications You must be signed in to change notification settings

amr/mimetypes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages