public final class MimeTypes extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT
The default
application/octet-stream MimeType |
| Modifier and Type | Method and Description |
|---|---|
MimeType |
forName(String name)
Return a MimeType from its name.
|
static MimeTypes |
get(String filepath,
Configuration conf)
Return a MimeTypes instance.
|
static MimeTypes |
get(String filepath,
org.apache.commons.logging.Log logger,
Configuration conf)
Return a MimeTypes instance.
|
MimeType |
getMimeType(byte[] data)
Find the Mime Content Type of a stream from its content.
|
MimeType |
getMimeType(File file)
Find the Mime Content Type of a file.
|
MimeType |
getMimeType(String name)
Find the Mime Content Type of a document from its name.
|
MimeType |
getMimeType(String name,
byte[] data)
Find the Mime Content Type of a document from its name and its content.
|
MimeType |
getMimeType(URL url)
Find the Mime Content Type of a document from its URL.
|
int |
getMinLength()
Return the minimum length of data to provide to analyzing methods
based on the document's content in order to check all the known
MimeTypes.
|
public static final String DEFAULT
application/octet-stream MimeTypepublic static MimeTypes get(String filepath, Configuration conf)
filepath - is the mime-types definitions xml file.public static MimeTypes get(String filepath, org.apache.commons.logging.Log logger, Configuration conf)
filepath - is the mime-types definitions xml file.logger - is it Logger to uses for ouput messages.public MimeType getMimeType(File file)
file - to analyze.null if none is found.public MimeType getMimeType(URL url)
url - of the document to analyze.null if none is found.public MimeType getMimeType(String name)
name - of the document to analyze.null if none is found.public MimeType getMimeType(byte[] data)
data - are the first bytes of data of the content to analyze.
Depending on the length of provided data, all known MimeTypes are
checked. If the length of provided data is greater or egals to
the value returned by getMinLength(), then all known
MimeTypes are checked, otherwise only the MimeTypes that could be
analyzed with the length of provided data are analyzed.null if none is found.getMinLength()public MimeType getMimeType(String name, byte[] data)
name - of the document to analyze.data - are the first bytes of the document's content.null if none is found.getMinLength()public int getMinLength()
getMimeType(byte[]),
getMimeType(String, byte[])Copyright © 2007, 2015, Oracle and/or its affiliates. All rights reserved.