public final class FileDataSource
extends java.lang.Object
implements javax.activation.DataSource
FileDataSource - A simple data source that encapsulates a file.| Constructor and Description |
|---|
FileDataSource(java.io.File file)
Creates a FileDataSource from a File object.
|
FileDataSource(java.io.File file,
java.lang.String contentType)
Creates a FileDataSource from a File object.
|
FileDataSource(java.lang.String name)
Creates a FileDataSource from the specified path name.
|
FileDataSource(java.lang.String name,
java.lang.String contentType)
Creates a FileDataSource from the specified path name.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getContentType() |
java.io.File |
getFile()
Return the file that corresponds to this FileDataSource.
|
java.io.InputStream |
getInputStream() |
java.lang.String |
getName() |
java.io.OutputStream |
getOutputStream() |
void |
setContentType(java.lang.String contentType)
Sets the content type.
|
void |
setName(java.lang.String name)
Sets the name (and implicitly content type).
|
static FileDataSource |
valueOf(java.io.InputStream inputStream)
Gets a file data source for specified input stream's data.
|
public FileDataSource(java.io.File file)
Content type is initially set to "application/octet-stream".
file - The filepublic FileDataSource(java.io.File file,
java.lang.String contentType)
file - The filecontentType - The content typepublic FileDataSource(java.lang.String name)
Content type is initially set to "application/octet-stream".
name - The system-dependent file name.public FileDataSource(java.lang.String name,
java.lang.String contentType)
Content type is initially set to "application/octet-stream".
name - The system-dependent file name.contentType - The content typepublic static FileDataSource valueOf(java.io.InputStream inputStream) throws java.io.IOException
inputStream - The input stream providing binary datajava.io.IOException - If an I/O error occurspublic java.io.InputStream getInputStream()
throws java.io.IOException
getInputStream in interface javax.activation.DataSourcejava.io.IOExceptionpublic java.io.OutputStream getOutputStream()
throws java.io.IOException
getOutputStream in interface javax.activation.DataSourcejava.io.IOExceptionpublic java.lang.String getContentType()
getContentType in interface javax.activation.DataSourcepublic java.lang.String getName()
getName in interface javax.activation.DataSourcepublic java.io.File getFile()
public void setContentType(java.lang.String contentType)
contentType - The content type.public void setName(java.lang.String name)
name - The name to set