Class MimeTypes


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

      Fields 
      Modifier and Type Field Description
      static java.lang.String APPLICATION_OCTET_STREAM
      constant for "application/octet-stream"
    • Constructor Summary

      Constructors 
      Constructor Description
      MimeTypes()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getExtension​(java.lang.String mimeType)
      Retrieve the default extension for the given mime type
      static java.lang.String getMimeType​(java.lang.String name)
      Retrieve the mimetype for the given extension or name
      static java.lang.String getMimeType​(java.lang.String name, java.lang.String defaultType)
      Retrieve the mimetype for the given extension or name
      static boolean hasExtension​(java.lang.String mimeType, java.lang.String ext)
      Checks if the given mime type is mapped to the extension
      static boolean isBinary​(java.lang.String mimeType)
      checks if the given mimetype denotes binary content
      static boolean matches​(java.lang.String name, java.lang.String mimeType, java.lang.String defaultType)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • APPLICATION_OCTET_STREAM

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

      • MimeTypes

        public MimeTypes()
    • Method Detail

      • getMimeType

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

        public static java.lang.String getMimeType​(java.lang.String name,
                                                   java.lang.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 java.lang.String getExtension​(java.lang.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​(java.lang.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​(java.lang.String mimeType,
                                           java.lang.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​(java.lang.String name,
                                      java.lang.String mimeType,
                                      java.lang.String defaultType)