Package org.htmlunit.util

# Class MimeType

java.lang.Object
org.htmlunit.util.MimeType

public final class MimeType extends Object
Utility holding information about association between MIME type and file extensions.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `APPLICATION_JSON`
  "application/json".
  `static final String`
  `APPLICATION_OCTET_STREAM`
  "application/octet-stream".
  `static final String`
  `APPLICATION_XHTML`
  application/xhtml+xml.
  `static final String`
  `APPLICATION_XML`
  application/xml.
  `static final String`
  `IMAGE_GIF`
  "image/gif".
  `static final String`
  `IMAGE_JPEG`
  "image/jpeg".
  `static final String`
  `IMAGE_PNG`
  "image/png".
  `static final String`
  `TEXT_CSS`
  "text/css".
  `static final String`
  `TEXT_HTML`
  "text/html".
  `static final String`
  `TEXT_JAVASCRIPT`
  "text/javascript".
  `static final String`
  `TEXT_PLAIN`
  "text/plain".
  `static final String`
  `TEXT_XML`
  "text/xml".

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `getFileExtension(String contentType)`
  Gets the preferred file extension for a content type.
  `static boolean`
  `isJavascriptMimeType(String mimeType)`
  See https://www.rfc-editor.org/rfc/rfc9239.html#name-iana-considerations.
  `static boolean`
  `isObsoleteJavascriptMimeType(String mimeType)`
  See https://mimesniff.spec.whatwg.org/#javascript-mime-type.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### TEXT_JAVASCRIPT

    public static final String TEXT_JAVASCRIPT
    "text/javascript".
    See Also:
      - Constant Field Values

  - ### APPLICATION_OCTET_STREAM

    public static final String APPLICATION_OCTET_STREAM
    "application/octet-stream".
    See Also:
      - Constant Field Values

  - ### APPLICATION_JSON

    public static final String APPLICATION_JSON
    "application/json".
    See Also:
      - Constant Field Values

  - ### APPLICATION_XHTML

    public static final String APPLICATION_XHTML
    application/xhtml+xml.
    See Also:
      - Constant Field Values

  - ### APPLICATION_XML

    public static final String APPLICATION_XML
    application/xml.
    See Also:
      - Constant Field Values

  - ### TEXT_CSS

    public static final String TEXT_CSS
    "text/css".
    See Also:
      - Constant Field Values

  - ### TEXT_HTML

    public static final String TEXT_HTML
    "text/html".
    See Also:
      - Constant Field Values

  - ### TEXT_XML

    public static final String TEXT_XML
    "text/xml".
    See Also:
      - Constant Field Values

  - ### TEXT_PLAIN

    public static final String TEXT_PLAIN
    "text/plain".
    See Also:
      - Constant Field Values

  - ### IMAGE_GIF

    public static final String IMAGE_GIF
    "image/gif".
    See Also:
      - Constant Field Values

  - ### IMAGE_JPEG

    public static final String IMAGE_JPEG
    "image/jpeg".
    See Also:
      - Constant Field Values

  - ### IMAGE_PNG

    public static final String IMAGE_PNG
    "image/png".
    See Also:
      - Constant Field Values

- ## Method Details

  - ### isJavascriptMimeType

    public static boolean isJavascriptMimeType(String mimeType)
    See https://www.rfc-editor.org/rfc/rfc9239.html#name-iana-considerations.
    Parameters:
      `mimeType` - the type to check
    Returns:
      true if the mime type is obsolete

  - ### isObsoleteJavascriptMimeType

    public static boolean isObsoleteJavascriptMimeType(String mimeType)
    See https://mimesniff.spec.whatwg.org/#javascript-mime-type.
    Parameters:
      `mimeType` - the type to check
    Returns:
      true if the mime type is for js

  - ### getFileExtension

    public static String getFileExtension(String contentType)
    Gets the preferred file extension for a content type.
    Parameters:
      `contentType` - the mime type
    Returns:
      `null` if none is known