Class MimeType


  • public class MimeType
    extends Object
    • Field Detail

      • MIME_APPLICATION_JSON

        public static final MimeType MIME_APPLICATION_JSON
      • MIME_APPLICATION_OCTET_STREAM

        public static final MimeType MIME_APPLICATION_OCTET_STREAM
      • MIME_APPLICATION_XML

        public static final MimeType MIME_APPLICATION_XML
      • MIME_IMAGE

        public static final MimeType MIME_IMAGE
      • MIME_IMAGE_JPEG

        public static final MimeType MIME_IMAGE_JPEG
      • MIME_IMAGE_PNG

        public static final MimeType MIME_IMAGE_PNG
      • MIME_IMAGE_TIF

        public static final MimeType MIME_IMAGE_TIF
      • MIME_TYPE_MARKDOWN

        public static final MimeType MIME_TYPE_MARKDOWN
      • MIME_WILDCARD

        public static final MimeType MIME_WILDCARD
    • Method Detail

      • fromExtension

        public static MimeType fromExtension​(String ext)
        Determine MIME type for the given file extension
        Parameters:
        ext - file extension
        Returns:
        corresponding MimeType
      • fromFilename

        public static MimeType fromFilename​(String filename)
        Determine MIME type from filename string. Returns null if no matching MIME type was found.
        Parameters:
        filename - filename including extension
        Returns:
        corresponding MimeType
      • fromTypename

        public static MimeType fromTypename​(String typeName)
        Given an existing MIME type name, look up the corresponding instance. An exception is made for vendor-specific types or non-standard types.
        Parameters:
        typeName - mimetype name as String, e.g. "image/jpeg"
        Returns:
        corresponding MimeType
      • fromURI

        public static MimeType fromURI​(URI uri)
        Determine MIME type from URI.
        Parameters:
        uri - uri including filename with extension
        Returns:
        corresponding MimeType
      • getExtensions

        public List<String> getExtensions()
        Get the known file extensions for the MIME type
        Returns:
        List of known file extensions for given MiemType
      • getPrimaryType

        public String getPrimaryType()
      • getSubType

        public String getSubType()
      • getSuffix

        public String getSuffix()
      • getTypeName

        public String getTypeName()
        Get the MIME type's name (e.g."application/json")
        Returns:
        the MimeType's type name as String
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • matches

        public boolean matches​(Object other)
        Check if the MIME type "matches" another MIME type.
        Parameters:
        other - Other MIME type to compare against
        Returns:
        Whether the other type matches this type