Package libcore.net

Class MimeUtils


  • public final class MimeUtils
    extends Object
    Utilities for dealing with MIME types. Used to implement java.net.URLConnection and android.webkit.MimeTypeMap.
    • Method Detail

      • hasMimeType

        public static boolean hasMimeType​(String mimeType)
        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

        public static String guessMimeTypeFromExtension​(String extension)
        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

        public static boolean hasExtension​(String extension)
        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

        public static String guessExtensionFromMimeType​(String mimeType)
        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.