/** * Load the default extensions from {@link #MIME_TYPE_EXTENSIONS_RESOURCE_PATH}, which can either be a property file or a * tab-delimited *nix-style MIME types file (common in web servers and libraries). If an extension applies to more than one * MIME type, the first one in the file wins. * * @return the default mappings; never null */ protected static Map<String, String> getDefaultMappings() { Map<String, Set<String>> duplicates = new HashMap<String, Set<String>>(); return load(Thread.currentThread().getContextClassLoader().getResourceAsStream(MIME_TYPE_EXTENSIONS_RESOURCE_PATH), duplicates); }
/** * Returns the MIME-type of the file using its name. If the MIME-type cannot be determined, a <code>null</code> is returned. * * @param file the file; may be <code>null</code>. * @return The MIME-type of the file, or optionally <code>null</code> if the MIME-type could not be determined. */ public String mimeTypeOf( File file ) { if (file == null) return null; return mimeTypeOf(file.getName()); } }
Map<String, String> mappings = initWithDefaults ? getDefaultMappings() : new HashMap<String, String>(); if (extensionsToMimeTypes != null) { for (Map.Entry<String, String> entry : extensionsToMimeTypes.entrySet()) {