Get MimeType of A File
Use activation.jar to access javax.activation API.
File file = new File("foo.jpg");alternatively , you can use filename to detech the mime type :
String mimeType = new MimetypesFileTypeMap().getContentType(file)); // image/jpeg
String mimeType = new MimetypesFileTypeMap().getContentType("foo.jpg")); // image/jpeg
Comments