public class MimeTypeMap extends Object
See also URLConnection.guessContentTypeFromName(java.lang.String)
and URLConnection.guessContentTypeFromStream(java.io.InputStream)
. This
class and URLConnection
share the same MIME-type database.
Modifier and Type | Method and Description |
---|---|
String |
getExtensionFromMimeType(String mimeType)
Return the registered extension for the given MIME type.
|
static String |
getFileExtensionFromUrl(String url)
Returns the file extension or an empty string iff there is no
extension.
|
String |
getMimeTypeFromExtension(String extension)
Return the MIME type for the given extension.
|
static MimeTypeMap |
getSingleton()
Get the singleton instance of MimeTypeMap.
|
boolean |
hasExtension(String extension)
Return true if the given extension has a registered MIME type.
|
boolean |
hasMimeType(String mimeType)
Return true if the given MIME type has an entry in the map.
|
public static String getFileExtensionFromUrl(String url)
url
- public boolean hasMimeType(String mimeType)
mimeType
- A MIME type (i.e. text/plain)public String getMimeTypeFromExtension(String extension)
extension
- A file extension without the leading '.'public boolean hasExtension(String extension)
extension
- A file extension without the leading '.'public String getExtensionFromMimeType(String mimeType)
mimeType
- A MIME type (i.e. text/plain)public static MimeTypeMap getSingleton()