Class MimeTypes

java.lang.Object
jodd.net.MimeTypes

public class MimeTypes extends Object
Map file extensions to MIME types. Based on the most recent Apache mime.types file. Duplicated extensions (wmz, sub) are manually resolved.

See also: http://www.iana.org/assignments/media-types/ http://www.webmaster-toolkit.com/mime-types.shtml

  • Field Details

  • Constructor Details

    • MimeTypes

      public MimeTypes()
  • Method Details

    • registerMimeType

      public static void registerMimeType(String ext, String mimeType)
      Registers MIME type for provided extension. Existing extension type will be overridden.
    • getMimeType

      public static String getMimeType(String ext)
      Returns the corresponding MIME type to the given extension. If no MIME type was found it returns application/octet-stream type.
    • lookupMimeType

      public static String lookupMimeType(String ext)
      Simply returns MIME type or null if no type is found.
    • findExtensionsByMimeTypes

      public static String[] findExtensionsByMimeTypes(String mimeType, boolean useWildcard)
      Finds all extensions that belong to given mime type(s). If wildcard mode is on, provided mime type is wildcard pattern.
      Parameters:
      mimeType - list of mime types, separated by comma
      useWildcard - if set, mime types are wildcard patterns
    • isRegisteredExtension

      public static boolean isRegisteredExtension(String extension)
      Returns true if given value is one of the registered MIME extensions.