Class MimeTypeUtil

java.lang.Object
ch.tocco.nice2.toolbox.api.mime.MimeTypeUtil

public final class MimeTypeUtil extends Object
Helper for mime type and file extension evaluation.
  • Field Details

    • MIME_TYPE_OCTET_STREAM

      public static final String MIME_TYPE_OCTET_STREAM
  • Method Details

    • getMimeType

      public static String getMimeType(File file, String filename)
      Returns the most specific mime type for the given File.
      Parameters:
      file - the file to inspect for its mimetype.
      Returns:
      the most specific mime type.
    • getMimeType

      public static String getMimeType(BufferedInputStream inputStream, String filename) throws IOException
      Returns the most specific mime type for the given BufferedInputStream.
      Parameters:
      inputStream - the input stream to inspect for its mimetype.
      Returns:
      the most specific mime type.
      Throws:
      IOException
    • getFileExtension

      public static String getFileExtension(String mimeType)
      Returns the typical file extension for the given mime type.
      Parameters:
      mimeType - the mime type for which to return the corresponding file extension.
      Returns:
      the file extension or empty string, if the mime type does not have a typical file extension.
    • loadTikaConfig

      public static org.apache.tika.config.TikaConfig loadTikaConfig()