java.lang.Object | +--javax.activation.FileDataSource
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. ThesetFileTypeMap
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
FileDataSource(java.io.File file) Creates a FileDataSource from a File object. | |
FileDataSource(java.lang.String name) Creates a FileDataSource from the specified path name. |
getContentType() This method returns the MIME type of the data in the form of a string. | |
getFile() Return the File object that corresponds to this FileDataSource. | |
getInputStream() This method will return an InputStream representing the the data and will throw an IOException if it can not do so. | |
getName() Return thename of this object. | |
getOutputStream() This method will return an OutputStream representing the the data and will throw an IOException if it can not do so. | |
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 |
publicFileDataSource(java.io.File file)
file
- the filepublicFileDataSource(java.lang.String name)
name
- the system-dependent file name.public java.io.InputStreamgetInputStream() throws java.io.IOException
getInputStream
in interfaceDataSource
public java.io.OutputStreamgetOutputStream() throws java.io.IOException
getOutputStream
in interfaceDataSource
public java.lang.StringgetContentType()
getDefaultFileTypeMap
method on FileTypeMap to acquire a default FileTypeMap.Note: By default, the FileTypeMap used will be a MimetypesFileTypeMap.getContentType
in interfaceDataSource
FileTypeMap.getDefaultFileTypeMap()
public java.lang.StringgetName()
getName
in interfaceDataSource
DataSource
public java.io.FilegetFile()
public voidsetFileTypeMap(FileTypeMap map)
map
- The FileTypeMap for this object.