Class MediaType



  • public final class MediaType
    extends Object
    An RFC 2045 Media Type, appropriate to describe the content type of an HTTP request or response body.
    • Method Summary

      Modifier and Type Method and Description
      Charset charset()
      Returns the charset of this media type, or null if this media type doesn't specify a charset.
      Charset charset(Charset defaultValue)
      Returns the charset of this media type, or defaultValue if this media type doesn't specify a charset.
      boolean equals(Object o)
       
      int hashCode()
       
      static MediaType parse(String string)
      Returns a media type for string, or null if string is not a well-formed media type.
      String subtype()
      Returns a specific media subtype, such as "plain" or "png", "mpeg", "mp4" or "xml".
      String toString()
      Returns the encoded media type, like "text/plain; charset=utf-8", appropriate for use in a Content-Type header.
      String type()
      Returns the high-level media type, such as "text", "image", "audio", "video", or "application".
    • Method Detail

      • parse

        public static MediaType parse(String string)
        Returns a media type for string, or null if string is not a well-formed media type.
      • type

        public String type()
        Returns the high-level media type, such as "text", "image", "audio", "video", or "application".
      • subtype

        public String subtype()
        Returns a specific media subtype, such as "plain" or "png", "mpeg", "mp4" or "xml".
      • charset

        public Charset charset()
        Returns the charset of this media type, or null if this media type doesn't specify a charset.
      • charset

        public Charset charset(Charset defaultValue)
        Returns the charset of this media type, or defaultValue if this media type doesn't specify a charset.
      • toString

        public String toString()
        Returns the encoded media type, like "text/plain; charset=utf-8", appropriate for use in a Content-Type header.
      • equals

        public boolean equals(Object o)
      • hashCode

        public int hashCode()