Class Mime


  • public final class Mime
    extends java.lang.Object
    Utilities for handling the MIME-Type header field.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String MIME_APP_JSON
      Json Mime type.
      static java.lang.String MIME_CSS
      CSS code MIME type.
      static java.lang.String MIME_DEFAULT_BINARY
      Binary code MIME type.
      static java.lang.String MIME_FORM_ENCODED_DATA
      Form Encoded Data MIME type.
      static java.lang.String MIME_GIF
      GIF files MIME type.
      static java.lang.String MIME_HTML
      HTML code MIME type.
      static java.lang.String MIME_JPEG
      JPEG files MIME type.
      static java.lang.String MIME_JS
      JavaScript code MIME type.
      static java.lang.String MIME_MULTIPART_FORM_ENCODED_DATA
      Multipart Form Encoded Data MIME type.
      static java.lang.String MIME_PLAINTEXT
      Standard text MIME type.
      static java.lang.String MIME_PNG
      PNG files MIME type.
      static java.lang.String MIME_XML
      XML code MIME type.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getMIMEType​(java.lang.String uri)
      Returns the MIME type from the name of the URI (file extension).
      static boolean mapFileExtensionToMIMEType​(java.lang.String fileExtension, java.lang.String mimeType)
      Define a mapping between a file extension and a MIME-Type.
      The mapping is defined only if the given file extension isn't already mapped to a MIME-Type.
      • Methods inherited from class java.lang.Object

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

      • MIME_PLAINTEXT

        public static final java.lang.String MIME_PLAINTEXT
        Standard text MIME type.
        See Also:
        Constant Field Values
      • MIME_HTML

        public static final java.lang.String MIME_HTML
        HTML code MIME type.
        See Also:
        Constant Field Values
      • MIME_XML

        public static final java.lang.String MIME_XML
        XML code MIME type.
        See Also:
        Constant Field Values
      • MIME_DEFAULT_BINARY

        public static final java.lang.String MIME_DEFAULT_BINARY
        Binary code MIME type.
        See Also:
        Constant Field Values
      • MIME_APP_JSON

        public static final java.lang.String MIME_APP_JSON
        Json Mime type.
        See Also:
        Constant Field Values
      • MIME_CSS

        public static final java.lang.String MIME_CSS
        CSS code MIME type.
        See Also:
        Constant Field Values
      • MIME_PNG

        public static final java.lang.String MIME_PNG
        PNG files MIME type.
        See Also:
        Constant Field Values
      • MIME_JPEG

        public static final java.lang.String MIME_JPEG
        JPEG files MIME type.
        See Also:
        Constant Field Values
      • MIME_GIF

        public static final java.lang.String MIME_GIF
        GIF files MIME type.
        See Also:
        Constant Field Values
      • MIME_JS

        public static final java.lang.String MIME_JS
        JavaScript code MIME type.
        See Also:
        Constant Field Values
      • MIME_FORM_ENCODED_DATA

        public static final java.lang.String MIME_FORM_ENCODED_DATA
        Form Encoded Data MIME type.
        See Also:
        Constant Field Values
      • MIME_MULTIPART_FORM_ENCODED_DATA

        public static final java.lang.String MIME_MULTIPART_FORM_ENCODED_DATA
        Multipart Form Encoded Data MIME type.
        See Also:
        Constant Field Values
    • Method Detail

      • getMIMEType

        @Nullable
        public static java.lang.String getMIMEType​(@Nullable
                                                   java.lang.String uri)
        Returns the MIME type from the name of the URI (file extension).
        Parameters:
        uri - the URI String to determine the MIME type (mapping between file extension and MIME type)
        Returns:
        null if the MIME type is unknown or URI is null
      • mapFileExtensionToMIMEType

        public static boolean mapFileExtensionToMIMEType​(java.lang.String fileExtension,
                                                         java.lang.String mimeType)
        Define a mapping between a file extension and a MIME-Type.
        The mapping is defined only if the given file extension isn't already mapped to a MIME-Type. A NullPointerException is thrown if one of the arguments is null
        Parameters:
        fileExtension - the file extension to be mapped to the mimeType
        mimeType - the MIME-Type to be associated with the given file extension.
        Returns:
        true if the mapping is successful, false otherwise (file extension already mapped to a MIME-Type)