|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.activation Class FileTypeMap
java.lang.Object javax.activation.FileTypeMap
- Direct Known Subclasses:
- MimetypesFileTypeMap
public abstract class FileTypeMap
- extends Object
FileTypeMap 是一个抽象类,它为文件提供数据分类接口。此类的实现将实现 getContentType 方法,该方法将从文件名或 File 对象得到内容类型。FileTypeMap 可以使用任一方案来确定数据类型,从检查文件的文件扩展名(如 MimetypesFileTypeMap)到打开文件并尝试从文件内容得到其类型。FileDataSource 类使用默认的 FileTypeMap(若无更改,则是 MimetypesFileTypeMap)来确定文件的内容类型。
See also | javax.activation.FileTypeMap, javax.activation.FileDataSource, javax.activation.MimetypesFileTypeMap |
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.
- See Also:
FileTypeMap
,FileDataSource
,MimetypesFileTypeMap
Constructor Summary | |
---|---|
FileTypeMap()
The default constructor. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public
FileTypeMap()
默认的构造方法。
英文文档:
FileTypeMap
public FileTypeMap()
- The default constructor.
Method Detail |
---|
abstract public String
getContentType(java.io.File file)
返回文件对象的类型。此方法应始终返回有效的 MIME 类型。
file | 要分类的文件。 |
return | 内容类型。 |
getContentType
public abstract String getContentType(File file)
- Return the type of the file object. This method should
always return a valid MIME type.
- Parameters:
file
- A file to be typed.- Returns:
- The content type.
abstract public String
getContentType(String filename)
返回传入文件的类型。此方法应始终返回有效的 MIME 类型。
filename | 文件的路径名。 |
return | 内容类型。 |
getContentType
public abstract String getContentType(String filename)
- Return the type of the file passed in. This method should
always return a valid MIME type.
- Parameters:
filename
- the pathname of the file.- Returns:
- The content type.
public static void
setDefaultFileTypeMap(FileTypeMap map)
设置系统的默认 FileTypeMap。此实例将返回给 getDefaultFileTypeMap 的调用者。
map | FileTypeMap。 |
Throws | SecurityException: 如果调用者不具有更改默认的权限 |
setDefaultFileTypeMap
public static void setDefaultFileTypeMap(FileTypeMap map)
- Sets the default FileTypeMap for the system. This instance
will be returned to callers of getDefaultFileTypeMap.
- Parameters:
map
- The FileTypeMap.- Throws:
SecurityException
- if the caller doesn't have permission to change the default
public static FileTypeMap
getDefaultFileTypeMap()
返回系统的默认 FileTypeMap。如果调用了 setDefaultFileTypeMap,则返回该实例,否则返回 MimetypesFileTypeMap
的一个实例。
return | 默认的 FileTypeMap |
See also | setDefaultFileTypeMap |
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
. - Returns:
- The default FileTypeMap
- See Also:
setDefaultFileTypeMap(javax.activation.FileTypeMap)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!