.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.
mime.types in the Java runtime.
META-INF/mime.types.
META-INF/mimetypes.default
(usually found only in the activation.jar file).
(The current implementation looks for the mime.types file
in the Java runtime in the directory java.home/conf
if it exists, and otherwise in the directory
java.home/lib, where java.home is the value
of the "java.home" System property. Note that the "conf" directory was
introduced in JDK 9.)
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"
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private MimeTypeFile[] | |
| private static final String | |
| private static final int |
| Access | Constructor and Description |
|---|---|
| public | |
| public | MimetypesFileTypeMap(String
the file name mimeTypeFileName)Construct a MimetypesFileTypeMap with programmatic entries added from the named file. |
| public | MimetypesFileTypeMap(InputStream
the input stream to read from is)Construct a MimetypesFileTypeMap with programmatic entries added from the InputStream. |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | addMimeTypes(String
A .mime.types formatted string of entries. mime_types)Prepend the MIME type values to the registry. |
| public String | Returns: the file's MIME typethe file f)Implements abstract javax. |
| public synchronized String | Returns: the file's MIME typethe file name filename)Implements abstract javax. |
| private void | |
| private MimeTypeFile | |
| private MimeTypeFile |
| confDir | back to summary |
|---|---|
| private static final String confDir | |
| DB | back to summary |
|---|---|
| private MimeTypeFile[] DB | |
| defaultType | back to summary |
|---|---|
| private static final String defaultType | |
| PROG | back to summary |
|---|---|
| private static final int PROG | |
| MimetypesFileTypeMap | back to summary |
|---|---|
| public MimetypesFileTypeMap() The default constructor. | |
| MimetypesFileTypeMap | back to summary |
|---|---|
| public MimetypesFileTypeMap(String mimeTypeFileName) throws IOException Construct a MimetypesFileTypeMap with programmatic entries added from the named file.
| |
| MimetypesFileTypeMap | back to summary |
|---|---|
| public MimetypesFileTypeMap(InputStream is) Construct a MimetypesFileTypeMap with programmatic entries added from the InputStream.
| |
| addMimeTypes | back to summary |
|---|---|
| public synchronized void addMimeTypes(String mime_types) Prepend the MIME type values to the registry.
| |
| getContentType | back to summary |
|---|---|
| public String getContentType(File f) Implements abstract javax. Return the MIME type of the file object.
The implementation in this class calls
| |
| getContentType | back to summary |
|---|---|
| public synchronized String getContentType(String filename) Implements abstract javax. 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. | |
| loadAllResources | back to summary |
|---|---|
| private void loadAllResources(Vector<E> v, String name) Load all of the named resource. | |
| loadFile | back to summary |
|---|---|
| private MimeTypeFile loadFile(String name) Load the named file. | |
| loadResource | back to summary |
|---|---|
| private MimeTypeFile loadResource(String name) Load from the named resource. | |