public class FileDataSource extends Objectimplements DataSource
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.
DataSource,
FileTypeMap,
MimetypesFileTypeMap
| Constructor and Description |
|---|
FileDataSource(File
Creates a FileDataSource from a File object.
|
FileDataSource(String
Creates a FileDataSource from the specified path name.
|
| Modifier and Type | Method and Description |
|---|---|
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
Set the FileTypeMap to use with this FileDataSource
|
public FileDataSource(Filefile)
file - the file
public FileDataSource(Stringname)
name - the system-dependent file name.
public InputStreamgetInputStream() throws IOException
getInputStream in interface
DataSource
IOException
public OutputStreamgetOutputStream() throws IOException
getOutputStream in interface
DataSource
IOException
public StringgetContentType()
getDefaultFileTypeMap method on FileTypeMap to acquire a default FileTypeMap.
Note: By default, the FileTypeMap used will be a MimetypesFileTypeMap.
getContentType in interface
DataSource
FileTypeMap.getDefaultFileTypeMap()
public StringgetName()
getName in interface
DataSource
DataSource
public FilegetFile()
public void setFileTypeMap(FileTypeMapmap)
map - The FileTypeMap for this object.