javax.activation

Class FileDataSource

Implemented Interfaces:
DataSource

public class FileDataSource
extends java.lang.Object
implements DataSource

Data source encapsulating a file.

Constructor Summary

FileDataSource(File file)
Constructor.
FileDataSource(String name)
Constructor.

Method Summary

String
getContentType()
Returns the MIME content type of the data.
File
getFile()
Returns the underlying file.
InputStream
getInputStream()
Returns an input stream from which the data can be read.
String
getName()
Returns the underlying name of this object.
OutputStream
getOutputStream()
Returns an output stream to which the data can be written.
void
setFileTypeMap(FileTypeMap map)
Sets the file type map to use to determine the content type of the file.

Constructor Details

FileDataSource

public FileDataSource(File file)
Constructor.
Parameters:
file - the underlying file to use

FileDataSource

public FileDataSource(String name)
Constructor.
Parameters:
name - the path to the underlying file to use

Method Details

getContentType

public String getContentType()
Returns the MIME content type of the data.
Specified by:
getContentType in interface DataSource

getFile

public File getFile()
Returns the underlying file.

getInputStream

public InputStream getInputStream()
            throws IOException
Returns an input stream from which the data can be read.
Specified by:
getInputStream in interface DataSource

getName

public String getName()
Returns the underlying name of this object.
Specified by:
getName in interface DataSource

getOutputStream

public OutputStream getOutputStream()
            throws IOException
Returns an output stream to which the data can be written.
Specified by:
getOutputStream in interface DataSource

setFileTypeMap

public void setFileTypeMap(FileTypeMap map)
Sets the file type map to use to determine the content type of the file.
Parameters:
map - the file type map