|
Java EE 5 SDK 深圳电信培训中心.徐海蛟老师. |
||||||||
上一个类 下一个类 | 框架 无框架 | ||||||||
摘要: 嵌套 | 字段 | 构造器 | 方法 | 详细信息: 字段 | 构造器 | 方法 |
javax.activation Class FileDataSource
java.lang.Object javax.activation.FileDataSource
- 所有已实现的接口:
- DataSource
public class FileDataSource
- extends Object
- implements DataSource
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.
构造器摘要 | |
---|---|
FileDataSource(File file)
Creates a FileDataSource from a File object. |
|
FileDataSource(String name)
Creates a FileDataSource from the specified path name. |
方法摘要 | |
---|---|
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 |
类方法继承 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
构造器详细信息 |
---|
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.
- 参数:
file
- the file
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.
- 参数:
name
- the system-dependent file name.
方法详细信息 |
---|
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.
- 规范说明:
getInputStream
in interfaceDataSource
- 返回:
- an InputStream
- 抛出异常:
IOException
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.
- 规范说明:
getOutputStream
in interfaceDataSource
- 返回:
- an OutputStream
- 抛出异常:
IOException
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. - 规范说明:
getContentType
in interfaceDataSource
- 返回:
- the MIME Type
- 另请参见:
FileTypeMap.getDefaultFileTypeMap()
getName
public String getName()
- Return the name of this object. The FileDataSource
will return the file name of the object.
- 规范说明:
getName
in interfaceDataSource
- 返回:
- the name of the object.
- 另请参见:
DataSource
getFile
public File getFile()
- Return the File object that corresponds to this FileDataSource.
- 返回:
- the File object for the file represented by this object.
setFileTypeMap
public void setFileTypeMap(FileTypeMap map)
- Set the FileTypeMap to use with this FileDataSource
- 参数:
map
- The FileTypeMap for this object.
|
Java EE 5 SDK 深圳电信培训中心.徐海蛟老师. |
||||||||
上一个类 下一个类 | 框架 无框架 | ||||||||
摘要: 嵌套 | 字段 | 构造器 | 方法 | 详细信息: 字段 | 构造器 | 方法 |
提交错误或意见
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.