MimeTypeMap is a simple java library for resolving the mime type from and extension and back. The code is based on the MimeTypeMap and MimeUtils classes from the Android SDK.
Get the latest code from GitHub using Git or download the repository as a ZIP file. (Download)
git clone https://github.com/diegoflassa/mimetypemap.git
This project uses Maven. Please refer to the following for additional information on how to install it.
You may build the library from the source by simply running the command bellow, in the console, from the project root folder.
mvn install
The following files will be generated in the "target" folder
* mimetypemap-x.x.x.jar
* mimetypemap-x.x.x-javadoc.jar
* mimetypemap-x.x.x-sources.jar
Add the mimetypemap-x.x.x.jar file to your project and use:
Obtain a MimeTypeMap instance
MimeTypeMap mtm= MimeTypeMap.getSingleton();
Obtain a extension from file in a URL
String ext= MimeTypeMap.getFileExtensionFromUrl("http://norvig.com/big.txt");
Obtain the extension from a mime-type
MimeTypeMap mtm= MimeTypeMap.getSingleton();
String ext= mtm.getExtensionFromMimeType("text/plain");
Obtain the mime-type from an extension
MimeTypeMap mtm= MimeTypeMap.getSingleton();
String type= mtm.getMimeTypeFromExtension("TXT");
Check if the library support given extension
MimeTypeMap mtm= MimeTypeMap.getSingleton();
Boolean hasExt= mtm.hasExtension("TXT");
Check if the library support given mime-type
MimeTypeMap mtm= MimeTypeMap.getSingleton();
Boolean hasType= mtm.hasMimeType("text/plain");
- See HISTORY.md
- See CONTRIBUTING.md
- See LICENSE