public class FileDataSource extends Object implements DataSource
filedatasource打字语义
的filedatasource类代表数据类型的文件对象的子类从filetypemap类。的setFileTypeMap
方法可以显式设置为filedatasource filetypemap实例。如果没有filetypemap设置的filedatasource会叫filetypemap的getdefaultfiletypemap方法得到系统的默认filetypemap。
DataSource
,
FileTypeMap
,
MimetypesFileTypeMap
Constructor and Description |
---|
FileDataSource(File file)
从文件创建对象的filedatasource。
|
FileDataSource(String name)
创建从指定的路径名filedatasource。
|
Modifier and Type | Method and Description |
---|---|
String |
getContentType()
此方法返回一个字符串形式的数据的MIME类型。
|
File |
getFile()
返回对应于该filedatasource文件对象。
|
InputStream |
getInputStream()
这个方法将返回一个InputStream和代表数据如果不能做抛出IOException。
|
String |
getName()
返回该对象的名称。
|
OutputStream |
getOutputStream()
这个方法将返回代表数据的一个OutputStream并且会做不到所以抛出IOException。
|
void |
setFileTypeMap(FileTypeMap map)
设置FileTypeMap使用这个filedatasource
|
public FileDataSource(File file)
file
-文件
public FileDataSource(String name)
name
-系统相关的文件名称。
public InputStream getInputStream() throws IOException
getInputStream
接口
DataSource
IOException
public OutputStream getOutputStream() throws IOException
getOutputStream
接口
DataSource
IOException
public String getContentType()
getDefaultFileTypeMap
方法获得一个默认的filetypemap。注意:默认情况下,使用的filetypemap将mimetypesfiletypemap。
getContentType
接口
DataSource
FileTypeMap.getDefaultFileTypeMap()
public String getName()
getName
接口
DataSource
DataSource
public File getFile()
public void setFileTypeMap(FileTypeMap map)
map
-此对象的filetypemap。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.