I want to get mimetype of a file can anyone please help me I want MIME Type like this...
File file=new File("example.jpeg");
String MimeTypeOfFile=/*files mimetype*/;
Thank You in Advance
I want to get mimetype of a file can anyone please help me I want MIME Type like this...
File file=new File("example.jpeg");
String MimeTypeOfFile=/*files mimetype*/;
Thank You in Advance
You can use the Apache Tika Library: It detects and extracts metadata and text from over a thousand different file types
http://tika.apache.org/0.7/detection.html
It has various methods like extension checking or reading file data to detect mime-type. It would be easy and efficient rather than writing yourself.
Example :
System.out.println(new Tika().detect(new File(PATH_TO_FILE)));