I use javax.activation.MimetypesFileTypeMap
. It starts with a small set: $JRE_HOME/lib/content-types.properties
, but you can add you own. Create a file mime.types
in the format shown in MimetypesFileTypeMap
's javadoc (I started with a large list from the net, massaged it, and added types I found missing). Now you can add that in your code by opening your mime.types
file and adding its contents to your map. However the easier solution is to add your mime.types
file to the META-INF
of your jar. java.activation
will pick that up automagically.