Search code examples
javajava-6java-5

Alternative to javax.activation.MimetypesFileTypeMap().getContentType(filename);


I have some code:

import javax.activation.MimetypesFileTypeMap;
...
..
.
String filename = "foo.xls"; // Where this can be any file name .doc, .pdf or whatever

String headerContentType = new MimetypesFileTypeMap().getContentType(filename);

It seems javax.activation.MimetypesFileTypeMap class is inside rt.jar which comes with JRE System library (jdk1.6.0_10) but not in jdk1.5.0

I would like to avoid the use of 1.6 libraries. Anyone knows an easy and quick alternative?


Solution

  • This comes from the activation framework. This is included as standard in Java 6, but is also available as a separate download (for use with Java 1.4 and above)