|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.activation Class FileDataSource
java.lang.Object javax.activation.FileDataSource
- All Implemented Interfaces:
- DataSource
public class FileDataSource
- extends Object
- implements DataSource
FileDataSource 类实现一个封装文件的简单 DataSource 对象。它通过 FileTypeMap 对象提供数据分类服务。
FileDataSource 分类语义
FileDataSource 类将文件的数据分类委托给一个从 FileTypeMap 类子类化的对象。setFileTypeMap
方法可用于为 FileDataSource 实例显示地设置 FileTypeMap。如果没有设置任何 FileTypeMap,则 FileDataSource 将调用 FileTypeMap 的 getDefaultFileTypeMap 方法获取系统的默认 FileTypeMap。
See also | javax.activation.DataSource, javax.activation.FileTypeMap, javax.activation.MimetypesFileTypeMap |
The FileDataSource class implements a simple DataSource object that encapsulates a file. It provides data typing services via a FileTypeMap object.
FileDataSource Typing Semantics
The FileDataSource class delegates data typing of files
to an object subclassed from the FileTypeMap class.
The setFileTypeMap
method can be used to explicitly
set the FileTypeMap for an instance of FileDataSource. If no
FileTypeMap is set, the FileDataSource will call the FileTypeMap's
getDefaultFileTypeMap method to get the System's default FileTypeMap.
- See Also:
DataSource
,FileTypeMap
,MimetypesFileTypeMap
Constructor Summary | |
---|---|
FileDataSource(File file)
Creates a FileDataSource from a File object. |
|
FileDataSource(String name)
Creates a FileDataSource from the specified path name. |
Method Summary | |
---|---|
String |
getContentType()
This method returns the MIME type of the data in the form of a string. |
File |
getFile()
Return the File object that corresponds to this FileDataSource. |
InputStream |
getInputStream()
This method will return an InputStream representing the the data and will throw an IOException if it can not do so. |
String |
getName()
Return the name of this object. |
OutputStream |
getOutputStream()
This method will return an OutputStream representing the the data and will throw an IOException if it can not do so. |
void |
setFileTypeMap(FileTypeMap map)
Set the FileTypeMap to use with this FileDataSource |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public
FileDataSource(java.io.File file)
根据 File 对象创建 FileDataSource。注:在调用要求文件打开的方法之前,文件实际上不会打开。
file | 文件 |
FileDataSource
public FileDataSource(File file)
- Creates a FileDataSource from a File object. Note:
The file will not actually be opened until a method is
called that requires the file to be opened.
- Parameters:
file
- the file
public
FileDataSource(String name)
根据指定的路径名创建 FileDataSource。注:在调用要求文件打开的方法之前,文件实际上不会打开。
name | 取决于系统的文件名。 |
FileDataSource
public FileDataSource(String name)
- Creates a FileDataSource from
the specified path name. Note:
The file will not actually be opened until a method is
called that requires the file to be opened.
- Parameters:
name
- the system-dependent file name.
Method Detail |
---|
public java.io.InputStream
getInputStream() throws java.io.IOException
此方法将返回一个表示数据的 InputStream;如果不能返回,则抛出 IOException。每次调用此方法都会返回一个新的 InputStream 实例。
return | InputStream |
getInputStream
public InputStream getInputStream() throws IOException
- This method will return an InputStream representing the
the data and will throw an IOException if it can
not do so. This method will return a new
instance of InputStream with each invocation.
- Specified by:
getInputStream
in interfaceDataSource
- Returns:
- an InputStream
- Throws:
IOException
public java.io.OutputStream
getOutputStream() throws java.io.IOException
此方法将返回一个表示数据的 OutputStream;如果不能返回,则抛出 IOException。每次调用此方法都会返回一个新的 OutputStream 实例。
return | OutputStream |
getOutputStream
public OutputStream getOutputStream() throws IOException
- This method will return an OutputStream representing the
the data and will throw an IOException if it can
not do so. This method will return a new instance of
OutputStream with each invocation.
- Specified by:
getOutputStream
in interfaceDataSource
- Returns:
- an OutputStream
- Throws:
IOException
public String
getContentType()
此方法以字符串形式返回数据的 MIME 类型。此方法使用当前安装的 FileTypeMap。如果没有显示地设置任何 FileTypeMap,FileDataSource 将对 FileTypeMap 调用 getDefaultFileTypeMap
方法获取默认的 FileTypeMap。注:默认情况下,使用的 FileTypeMap 是 MimetypesFileTypeMap。
return | MIME 类型 |
See also | getDefaultFileTypeMap |
getContentType
public String getContentType()
- This method returns the MIME type of the data in the form of a
string. This method uses the currently installed FileTypeMap. If
there is no FileTypeMap explictly set, the FileDataSource will
call the
getDefaultFileTypeMap
method on FileTypeMap to acquire a default FileTypeMap. Note: By default, the FileTypeMap used will be a MimetypesFileTypeMap. - Specified by:
getContentType
in interfaceDataSource
- Returns:
- the MIME Type
- See Also:
FileTypeMap.getDefaultFileTypeMap()
public String
getName()
返回此对象的名称。FileDataSource 将返回对象的文件名。
return | 对象的名称。 |
See also | javax.activation.DataSource |
getName
public String getName()
- Return the name of this object. The FileDataSource
will return the file name of the object.
- Specified by:
getName
in interfaceDataSource
- Returns:
- the name of the object.
- See Also:
DataSource
public java.io.File
getFile()
返回与此 FileDataSource 对应的 File 对象。
return | 此对象表示的文件的 File 对象。 |
getFile
public File getFile()
- Return the File object that corresponds to this FileDataSource.
- Returns:
- the File object for the file represented by this object.
public void
setFileTypeMap(FileTypeMap map)
设置用于此 FileDataSource 的 FileTypeMap。
map | 此对象的 FileTypeMap。 |
setFileTypeMap
public void setFileTypeMap(FileTypeMap map)
- Set the FileTypeMap to use with this FileDataSource
- Parameters:
map
- The FileTypeMap for this object.
|
|||||||||
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 : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!