public class MimetypesFileTypeMap extends FileTypeMap
This class extends FileTypeMap and provides data typing of files via their file extension. It uses the
MIME types file search order:
The MimetypesFileTypeMap looks in various places in the user's system for MIME types file entries. When requests are made to search for MIME types in the MimetypesFileTypeMap, it searches MIME types files in the following order:
.mime.typesin the user's home directory.
META-INF/mimetypes.default(usually found only in the
MIME types file format:
# comments begin with a '#'
# the format is <mime type> <space separated file extensions>
# for example:
text/plain txt text TXT
# this would map file.txt, file.text, and file.TXT to
# the mime type "text/plain"
The default constructor.
public MimetypesFileTypeMap(String mimeTypeFileName) throws IOException
Construct a MimetypesFileTypeMap with programmatic entries added from the named file.
mimeTypeFileName- the file name
public MimetypesFileTypeMap(InputStream is)
Construct a MimetypesFileTypeMap with programmatic entries added from the InputStream.
is- the input stream to read from
public void addMimeTypes(String mime_types)
Prepend the MIME type values to the registry.
mime_types- A .mime.types formatted string of entries.
public String getContentType(File f)
Return the MIME type of the file object. The implementation in this class calls
f- the file
public String getContentType(String filename)
Return the MIME type based on the specified file name. The MIME type entries are searched as described above under MIME types file search order. If no entry is found, the type "application/octet-stream" is returned.
filename- the file name
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.