public final class MimeType2ExtMap
extends java.lang.Object
MimeType2ExtMap
- Maps MIME types to file extensions and vice versa.
This class looks in various places for MIME types file entries. When requests are made to look up MIME types or file extensions, it searches MIME types files in the following order:
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getContentType(java.io.File file)
Gets the MIME type associated with given file.
|
static java.lang.String |
getContentType(java.lang.String fileName)
Gets the MIME type associated with given file name.
|
static java.lang.String |
getContentTypeByExtension(java.lang.String extension)
Gets the MIME type associated with given file extension.
|
static java.lang.String |
getFileExtension(java.lang.String mimeType)
Gets the file extension for given MIME type.
|
static java.util.List<java.lang.String> |
getFileExtensions(java.lang.String mimeType)
Gets the file extension for given MIME type.
|
static void |
init()
Initializes MIME type file map.
|
static void |
load(java.io.File file)
Loads the MIME type file specified through given file.
|
static void |
load(java.lang.String fileStr)
Loads the MIME type file specified through
fileStr . |
static void |
reset()
Resets MIME type file map.
|
public static void reset()
public static void init()
public static java.lang.String getContentType(java.io.File file)
file
- The fileapplication/octet-stream
if none foundpublic static java.lang.String getContentType(java.lang.String fileName)
fileName
- The file name; e.g. "file.html"
application/octet-stream
if none foundpublic static java.lang.String getContentTypeByExtension(java.lang.String extension)
extension
- The file extension; e.g. "txt"
application/octet-stream
if none foundpublic static java.util.List<java.lang.String> getFileExtensions(java.lang.String mimeType)
mimeType
- The MIME typedat
if none foundpublic static java.lang.String getFileExtension(java.lang.String mimeType)
mimeType
- The MIME typedat
if none foundpublic static void load(java.lang.String fileStr)
fileStr
.fileStr
- The MIME type file to loadpublic static void load(java.io.File file)
file
- The MIME type file to load