Package ch.tocco.nice2.toolbox.api.mime
Class MimeTypeUtil
java.lang.Object
ch.tocco.nice2.toolbox.api.mime.MimeTypeUtil
Helper for mime type and file extension evaluation.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getFileExtension
(String mimeType) Returns the typical file extension for the given mime type.static String
getMimeType
(BufferedInputStream inputStream, String filename) Returns the most specific mime type for the givenBufferedInputStream
.static String
getMimeType
(File file, String filename) Returns the most specific mime type for the givenFile
.static org.apache.tika.config.TikaConfig
-
Field Details
-
MIME_TYPE_OCTET_STREAM
-
-
Method Details
-
getMimeType
Returns the most specific mime type for the givenFile
.- 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 givenBufferedInputStream
.- Parameters:
inputStream
- the input stream to inspect for its mimetype.- Returns:
- the most specific mime type.
- Throws:
IOException
-
getFileExtension
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()
-