public class MimeTypesUtil
extends java.lang.Object
| Constructor and Description |
|---|
MimeTypesUtil() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
getContentType(java.io.File file)
Returns the content type from the file.
|
static java.lang.String |
getContentType(java.io.File file,
java.lang.String fileName)
Returns the content type from the file and file name.
|
static java.lang.String |
getContentType(java.io.InputStream inputStream,
java.lang.String fileName)
Returns the content type from the input stream and file name.
|
static java.lang.String |
getContentType(java.lang.String fileName)
Returns the content type from the file name.
|
static java.lang.String |
getExtensionContentType(java.lang.String extension)
Returns the content type from the file extension.
|
static java.util.Set<java.lang.String> |
getExtensions(java.lang.String contentType)
Returns the possible file extensions for the content type.
|
static MimeTypes |
getMimeTypes() |
static boolean |
isWebImage(java.lang.String mimeType) |
void |
setMimeTypes(MimeTypes mimeTypes) |
public static java.lang.String getContentType(java.io.File file)
file - the file of the contentpublic static java.lang.String getContentType(java.io.File file,
java.lang.String fileName)
file - the file of the content (optionally null)fileName - the full name or extension of the file (e.g.,
"Test.doc", ".doc")public static java.lang.String getContentType(java.io.InputStream inputStream,
java.lang.String fileName)
The input stream is not reset upon return of this method. This needs to
be handled by the caller if the input stream is to be reused.
Alternatively, use the method getContentType(File, String).
inputStream - the input stream of the content (optionally
null)fileName - the full name or extension of the file (e.g.,
"Test.doc", ".doc")public static java.lang.String getContentType(java.lang.String fileName)
fileName - the full name or extension of the file (e.g.,
"Test.doc", ".doc")public static java.lang.String getExtensionContentType(java.lang.String extension)
extension - the extension of the file (e.g., "doc")public static java.util.Set<java.lang.String> getExtensions(java.lang.String contentType)
contentType - the content type of the file (e.g., "image/jpeg")public static MimeTypes getMimeTypes()
public static boolean isWebImage(java.lang.String mimeType)
public void setMimeTypes(MimeTypes mimeTypes)