Class MimeTypes


  • public class MimeTypes
    extends Object
    MimeTypes contains a mapping from extensions to mime types.
    • Field Detail

      • APPLICATION_OCTET_STREAM

        public static final String APPLICATION_OCTET_STREAM
        constant for "application/octet-stream"
        See Also:
        Constant Field Values
    • Constructor Detail

      • MimeTypes

        public MimeTypes()
    • Method Detail

      • getMimeType

        public static String getMimeType​(String name)
        Retrieve the mimetype for the given extension or name
        Parameters:
        name - the name
        Returns:
        the mimetype or null
      • getMimeType

        public static String getMimeType​(String name,
                                         String defaultType)
        Retrieve the mimetype for the given extension or name
        Parameters:
        name - the name
        defaultType - type to return if no mapping is found.
        Returns:
        the mimetype or null
      • getExtension

        public static String getExtension​(String mimeType)
        Retrieve the default extension for the given mime type
        Parameters:
        mimeType - the mime type
        Returns:
        the extension or null
      • isBinary

        public static boolean isBinary​(String mimeType)
        checks if the given mimetype denotes binary content
        Parameters:
        mimeType - the mime type
        Returns:
        true if binary or if mimeType is null
      • hasExtension

        public static boolean hasExtension​(String mimeType,
                                           String ext)
        Checks if the given mime type is mapped to the extension
        Parameters:
        mimeType - the mime type
        ext - the extension
        Returns:
        true if the given mime type contains that extension
      • matches

        public static boolean matches​(String name,
                                      String mimeType,
                                      String defaultType)