com.liferay.portal.kernel.util
Class MimeTypesUtil
java.lang.Object
com.liferay.portal.kernel.util.MimeTypesUtil
public class MimeTypesUtil
- extends java.lang.Object
- Author:
- Jorge Ferrer, Brian Wing Shun Chan, Alexander Chow
|
Method Summary |
static java.lang.String |
getContentType(java.io.File file)
|
static java.lang.String |
getContentType(java.io.File file,
java.lang.String fileName)
|
static java.lang.String |
getContentType(java.io.InputStream inputStream,
java.lang.String fileName)
Determine the content type from an input stream and file name. |
static java.lang.String |
getContentType(java.lang.String fileName)
Determine the content type from a file name. |
static java.util.Set<java.lang.String> |
getExtensions(java.lang.String contentType)
Determine the possible file extensions for a given content type. |
static MimeTypes |
getMimeTypes()
|
void |
setMimeTypes(MimeTypes mimeTypes)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MimeTypesUtil
public MimeTypesUtil()
getContentType
public static java.lang.String getContentType(java.io.File file)
getContentType
public static java.lang.String getContentType(java.io.File file,
java.lang.String fileName)
getContentType
public static java.lang.String getContentType(java.io.InputStream inputStream,
java.lang.String fileName)
- Determine the content type from an input stream and file name.
- Parameters:
fileName - full name or extension of file (e.g., "Test.doc",
".doc")
- Returns:
- content type if it is a supported format or an empty string if it
is an unsupported format
getContentType
public static java.lang.String getContentType(java.lang.String fileName)
- Determine the content type from a file name.
- Parameters:
fileName - full name or extension of file (e.g., "Test.doc",
".doc")
- Returns:
- content type if it is a supported format or an empty string if it
is an unsupported format
getExtensions
public static java.util.Set<java.lang.String> getExtensions(java.lang.String contentType)
- Determine the possible file extensions for a given content type.
- Parameters:
contentType - content type of file (e.g., "image/jpeg")
- Returns:
- set of extensions if it is a known content type or an empty set
if it is an unknown content type
getMimeTypes
public static MimeTypes getMimeTypes()
setMimeTypes
public void setMimeTypes(MimeTypes mimeTypes)