Package libcore.net
Class MimeUtils
java.lang.Object
libcore.net.MimeUtils
public final class MimeUtils extends Object
Utilities for dealing with MIME types.
Used to implement java.net.URLConnection and android.webkit.MimeTypeMap.
-
Method Summary
Modifier and Type Method Description static StringguessExtensionFromMimeType(String mimeType)Returns the registered extension for the given MIME type.static StringguessMimeTypeFromExtension(String extension)Returns the MIME type for the given extension.static booleanhasExtension(String extension)Returns true if the given extension has a registered MIME type.static booleanhasMimeType(String mimeType)Returns true if the given MIME type has an entry in the map.
-
Method Details
-
hasMimeType
Returns true if the given MIME type has an entry in the map.- Parameters:
mimeType- A MIME type (i.e. text/plain)- Returns:
- True iff there is a mimeType entry in the map.
-
guessMimeTypeFromExtension
Returns the MIME type for the given extension.- Parameters:
extension- A file extension without the leading '.'- Returns:
- The MIME type for the given extension or null iff there is none.
-
hasExtension
Returns true if the given extension has a registered MIME type.- Parameters:
extension- A file extension without the leading '.'- Returns:
- True iff there is an extension entry in the map.
-
guessExtensionFromMimeType
Returns the registered extension for the given MIME type. Note that some MIME types map to multiple extensions. This call will return the most common extension for the given MIME type.- Parameters:
mimeType- A MIME type (i.e. text/plain)- Returns:
- The extension for the given MIME type or null iff there is none.
-