Class Mime


  • public final class Mime
    extends Object
    Utilities for handling the MIME-Type header field.
    • Method Detail

      • getMIMEType

        @Nullable
        public static String getMIMEType​(@Nullable
                                         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​(String fileExtension,
                                                         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)