Question

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?

Was it helpful?

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)

OTHER TIPS

The particular class is actually part of the java bean s activation framework;

JAF Download

It should not be dependant on 1.6 as far as I know. So simply download the jar, and ensure you have the mimetypes.default available on your classpath.

I've used with success this project SubLuna, it seems more complete than JAF. It uses this mime type collection : Shared MIME Info Specification which is well maintained(of course you will have to replace the file that comes with the library).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top