FileTypeMap (Java EE 5 SDK)

Java

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


javax.activation Class FileTypeMap

java.lang.Object
  extended by javax.activation.FileTypeMap
直接已知子类:
MimetypesFileTypeMap

public abstract class FileTypeMap
extends Object

The FileTypeMap is an abstract class that provides a data typing interface for files. Implementations of this class will implement the getContentType methods which will derive a content type from a file name or a File object. FileTypeMaps could use any scheme to determine the data type, from examining the file extension of a file (like the MimetypesFileTypeMap) to opening the file and trying to derive its type from the contents of the file. The FileDataSource class uses the default FileTypeMap (a MimetypesFileTypeMap unless changed) to determine the content type of files.

另请参见:
FileTypeMap, FileDataSource, MimetypesFileTypeMap

构造器摘要
FileTypeMap()
          The default constructor.
 
方法摘要
abstract  String getContentType(File file)
          Return the type of the file object.
abstract  String getContentType(String filename)
          Return the type of the file passed in.
static FileTypeMap getDefaultFileTypeMap()
          Return the default FileTypeMap for the system.
static void setDefaultFileTypeMap(FileTypeMap map)
          Sets the default FileTypeMap for the system.
 
类方法继承 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造器详细信息

FileTypeMap

public FileTypeMap()
The default constructor.

方法详细信息

getContentType

public abstract String getContentType(File file)
Return the type of the file object. This method should always return a valid MIME type.

参数:
file - A file to be typed.
返回:
The content type.

getContentType

public abstract String getContentType(String filename)
Return the type of the file passed in. This method should always return a valid MIME type.

参数:
filename - the pathname of the file.
返回:
The content type.

setDefaultFileTypeMap

public static void setDefaultFileTypeMap(FileTypeMap map)
Sets the default FileTypeMap for the system. This instance will be returned to callers of getDefaultFileTypeMap.

参数:
map - The FileTypeMap.
抛出异常:
SecurityException - if the caller doesn't have permission to change the default

getDefaultFileTypeMap

public static FileTypeMap getDefaultFileTypeMap()
Return the default FileTypeMap for the system. If setDefaultFileTypeMap was called, return that instance, otherwise return an instance of MimetypesFileTypeMap.

返回:
The default FileTypeMap
另请参见:
setDefaultFileTypeMap(javax.activation.FileTypeMap)

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


提交错误或意见

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.