Class MimeTypeFile

java.lang.Object
ch.autumo.commons.mime.MimeTypeFile
All Implemented Interfaces:
jakarta.activation.MimeTypeRegistry

public class MimeTypeFile extends Object implements jakarta.activation.MimeTypeRegistry
Mime type file. Patched: autumo GmbH, Michael Gasche
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
      Logger.
  • Constructor Details

    • MimeTypeFile

      public MimeTypeFile(String mimeTypesfile) throws IOException
      Construct with mime types file ("mime.types" usually).
      Parameters:
      mimeTypesfile - The file name of the mime types file.
      Throws:
      IOException - if MIME type file cannot be read
    • MimeTypeFile

      public MimeTypeFile(InputStream is) throws IOException
      Construct with mime types input stream ( from"mime.types" usually).
      Parameters:
      is - input stream
      Throws:
      IOException - if MIME type file cannot be read
    • MimeTypeFile

      public MimeTypeFile()
      Creates an empty mime types registry.
  • Method Details

    • getMimeTypeEntry

      public jakarta.activation.MimeTypeEntry getMimeTypeEntry(String ext)
      Get a mime type entry based on the file extension.
      Specified by:
      getMimeTypeEntry in interface jakarta.activation.MimeTypeRegistry
      Parameters:
      ext - the file extension
      Returns:
      one mime type entry
    • getMIMETypeString

      public String getMIMETypeString(String ext)
      Get a mime type entry based on the file extension.
      Specified by:
      getMIMETypeString in interface jakarta.activation.MimeTypeRegistry
      Parameters:
      ext - the file extension
      Returns:
      the MIME type string
    • appendToRegistry

      public void appendToRegistry(String mime_types)
      Appends string of entries to the types registry, must be valid mime.types format. A mime.types entry is one of two forms type/subtype ext1 ext2 ... or type=type/subtype desc="description of type" exts=ext1,ext2,... Example # this is a test audio/basic au text/plain txt text type=application/postscript exts=ps,eps
      Specified by:
      appendToRegistry in interface jakarta.activation.MimeTypeRegistry
      Parameters:
      mime_types - the mime.types string