Class MimeTypes


  • public class MimeTypes
    extends java.lang.Object
    MIME Type enum and utilities
    • Constructor Detail

      • MimeTypes

        public MimeTypes()
        Constructor.
    • Method Detail

      • getMimeMap

        public java.util.Map<java.lang.String,​java.lang.String> getMimeMap()
      • setMimeMap

        public void setMimeMap​(java.util.Map<java.lang.String,​java.lang.String> mimeMap)
        Parameters:
        mimeMap - A Map of file extension to mime-type.
      • getDefaultMimeByExtension

        public static java.lang.String getDefaultMimeByExtension​(java.lang.String filename)
        Get the MIME type by filename extension. Lookup only the static default mime map.
        Parameters:
        filename - A file name
        Returns:
        MIME type matching the longest dot extension of the file name.
      • getMimeByExtension

        public java.lang.String getMimeByExtension​(java.lang.String filename)
        Get the MIME type by filename extension. Lookup the content and static default mime maps.
        Parameters:
        filename - A file name
        Returns:
        MIME type matching the longest dot extension of the file name.
      • addMimeMapping

        public void addMimeMapping​(java.lang.String extension,
                                   java.lang.String type)
        Set a mime mapping
        Parameters:
        extension - the extension
        type - the mime type
      • getKnownMimeTypes

        public static java.util.Set<java.lang.String> getKnownMimeTypes()
      • getCharsetFromContentType

        public static java.lang.String getCharsetFromContentType​(java.lang.String value)
      • getInferredEncodings

        public static java.util.Map<java.lang.String,​java.lang.String> getInferredEncodings()
        Access a mutable map of mime type to the charset inferred from that content type. An inferred encoding is used by when encoding/decoding a stream and is explicitly set in any metadata (eg Content-Type).
        Returns:
        Map of mime type to charset
      • getAssumedEncodings

        public static java.util.Map<java.lang.String,​java.lang.String> getAssumedEncodings()
        Access a mutable map of mime type to the charset assumed for that content type. An assumed encoding is used by when encoding/decoding a stream, but is not explicitly set in any metadata (eg Content-Type).
        Returns:
        Map of mime type to charset
      • inferCharsetFromContentType

        @Deprecated
        public static java.lang.String inferCharsetFromContentType​(java.lang.String contentType)
        Deprecated.
      • getCharsetInferredFromContentType

        public static java.lang.String getCharsetInferredFromContentType​(java.lang.String contentType)
      • getCharsetAssumedFromContentType

        public static java.lang.String getCharsetAssumedFromContentType​(java.lang.String contentType)
      • getContentTypeWithoutCharset

        public static java.lang.String getContentTypeWithoutCharset​(java.lang.String value)