There is a handy Java library that will inspect the bytes to determine the Mime type. The library can be found here:
MimeUtil
It's fairly easy to use. An example code is shown below:
byte[] bytes;
MimeUtil.registerMimeDetector("eu.medsea.mimeutil.detector.MimeMagicMimeDetector");
MimeUtil.getMimeTypes(bytes);
MimeUtil.unregisterMimeDetector("eu.medsea.mimeutil.detector.MimeMagicMimeDetector");
No comments:
Post a Comment