How to get a file’s Media Type (MIME type)?

How do you get a Media Type (MIME type) from a file using Java? So far I’ve tried JMimeMagic & Mime-Util. The first gave me memory exceptions, the second doesn’t close its streams properly.

How would you probe the file to determine its actual type (not merely based on the extension)?

28 Answers
28

Leave a Comment