public class MimetypesFileTypeMap extends FileTypeMap
.mime.types
format. 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.types
in the user's home directory.
/lib/mime.types
.
META-INF/mime.types
.
META-INF/mimetypes.default
(usually found only in the activation.jar
file).
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"
Constructor and Description |
---|
MimetypesFileTypeMap()
The default constructor.
|
MimetypesFileTypeMap(InputStream is)
Construct a MimetypesFileTypeMap with programmatic entries
added from the InputStream.
|
MimetypesFileTypeMap(String mimeTypeFileName)
Construct a MimetypesFileTypeMap with programmatic entries
added from the named file.
|
Modifier and Type | Method and Description |
---|---|
void |
addMimeTypes(String mime_types)
Prepend the MIME type values to the registry.
|
String |
getContentType(File f)
Return the MIME type of the file object.
|
String |
getContentType(String filename)
Return the MIME type based on the specified file name.
|
getDefaultFileTypeMap, setDefaultFileTypeMap
public MimetypesFileTypeMap()
public MimetypesFileTypeMap(String mimeTypeFileName) throws IOException
mimeTypeFileName
- the file nameIOException
public MimetypesFileTypeMap(InputStream is)
is
- the input stream to read frompublic void addMimeTypes(String mime_types)
mime_types
- A .mime.types formatted string of entries.public String getContentType(File f)
getContentType(f.getName())
.getContentType
in class FileTypeMap
f
- the filepublic String getContentType(String filename)
getContentType
in class FileTypeMap
filename
- the file name Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2011, Oracle and/or its affiliates. All rights reserved.
DRAFT ea-b138