wro4j-core/src/main/java/ro/isdc/wro/http/support/ContentTypeResolver.java
public static String get(final String fileName) {
    final String extension = FilenameUtils.getExtension(WroUtil.removeQueryString(fileName.toLowerCase()));
    if (defaultContentTypeMap.containsKey(extension)) {
      return defaultContentTypeMap.get(extension);
    }
    try {
      final Class<?> fileTypeMapClass = ClassLoader.getSystemClassLoader().loadClass("javax.activation.FileTypeMap");
      LOG.debug("using {} to resolve contentType", fileTypeMapClass.getName());
      final Object fileTypeMap = fileTypeMapClass.getMethod("getDefaultFileTypeMap").invoke(fileTypeMapClass);
      return (String) fileTypeMapClass.getMethod("getContentType", String.class).invoke(fileTypeMap, fileName);
    } catch (final Exception e) {
      LOG.debug("FileTypeMap is not available (probably jdk5 is used). Exception {}, with message: {}", e.getClass(),
          e.getMessage());
      LOG.debug("Will use default content type: {} for fileName: {}", DEFAULT_CONTENT_TYPE, fileName);
    }
    return DEFAULT_CONTENT_TYPE;
  }
public static String get(final String fileName) {
    final String extension = FilenameUtils.getExtension(WroUtil.removeQueryString(fileName.toLowerCase()));
    if (defaultContentTypeMap.containsKey(extension)) {
      return defaultContentTypeMap.get(extension);
    }
    try {
      final Class<?> fileTypeMapClass = ClassLoader.getSystemClassLoader().loadClass("javax.activation.FileTypeMap");
      LOG.debug("using {} to resolve contentType", fileTypeMapClass.getName());
      final Object fileTypeMap = fileTypeMapClass.getMethod("getDefaultFileTypeMap").invoke(fileTypeMapClass);
      return (String) fileTypeMapClass.getMethod("getContentType", String.class).invoke(fileTypeMap, fileName);
    } catch (final Exception e) {
      LOG.debug("FileTypeMap is not available (probably jdk5 is used). Exception {}, with message: {}", e.getClass(),
          e.getMessage());
      LOG.debug("Will use default content type: {} for fileName: {}", DEFAULT_CONTENT_TYPE, fileName);
    }
    return DEFAULT_CONTENT_TYPE;
  }
Returns a valid HTTP contentType's for a given filename. It first relies on the custom defaultContentTypeMap and if
not found it will fall back to defaultFileTypeMap from javax.activation.FileTypeMap. Examples: - "somefile.css"
resolves to "text/css". - "somefile.js.png" resolves to "image/png" - "/blah/index.html resolves to "text/html".
<p/>
The implementation uses reflection to load <code>javax.activation.FileTypeMap</code> class (available in jdk6) in
order to be compatible with jdk5. If this class is not available, the default content type is returned.

@param fileName
with an filename extension
@return contentType