Liferay 6.2.0-ce-m1

com.liferay.portal.kernel.util
Class MimeTypesUtil

java.lang.Object
  extended by com.liferay.portal.kernel.util.MimeTypesUtil

public class MimeTypesUtil
extends Object


Constructor Summary
MimeTypesUtil()
           
 
Method Summary
static String getContentType(File file)
           
static String getContentType(File file, String fileName)
           
static String getContentType(InputStream inputStream, String fileName)
          Returns the content type from an input stream and file name.
static String getContentType(String fileName)
          Returns the content type from a file name.
static Set<String> getExtensions(String contentType)
          Returns the possible file extensions for a given content type.
static MimeTypes getMimeTypes()
           
static boolean isWebImage(String mimeType)
           
 void setMimeTypes(MimeTypes mimeTypes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimeTypesUtil

public MimeTypesUtil()
Method Detail

getContentType

public static String getContentType(File file)

getContentType

public static String getContentType(File file,
                                    String fileName)

getContentType

public static String getContentType(InputStream inputStream,
                                    String fileName)
Returns the content type from an input stream and file name.

Parameters:
inputStream - the input stream of the content (optionally null)
fileName - the full name or extension of file (e.g., "Test.doc", ".doc")
Returns:
the content type if it is a supported format or an empty string if it is an unsupported format

getContentType

public static String getContentType(String fileName)
Returns the content type from a file name.

Parameters:
fileName - the full name or extension of the file (e.g., "Test.doc", ".doc")
Returns:
the content type if it is a supported format or an empty string if it is an unsupported format

getExtensions

public static Set<String> getExtensions(String contentType)
Returns the possible file extensions for a given content type.

Parameters:
contentType - the content type of the file (e.g., "image/jpeg")
Returns:
the 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()

isWebImage

public static boolean isWebImage(String mimeType)

setMimeTypes

public void setMimeTypes(MimeTypes mimeTypes)

Liferay 6.2.0-ce-m1