net.sf.basedb.ws.server
Class TempFileDataSource
java.lang.Object
javax.activation.FileDataSource
net.sf.basedb.ws.server.TempFileDataSource
- All Implemented Interfaces:
- DataSource
public class TempFileDataSource
- extends FileDataSource
A DataSource implementation for temporary files. The temporary
file will be deleted once the entire file has been read or the
close() method is called on the InputStream.
Since this may cause problems if the getInputStream()
is called more than once, the file deletion is disabled if
that happens. Instead the File.deleteOnExit()
is
called to mark the file for deletion when the virtual machine exits.
- Version:
- 2.5
- Author:
- nicklas
- Last modified
- $Date: 2008-09-11 22:06:36 +0200 (Thu, 11 Sep 2008) $
Nested Class Summary |
private class |
TempFileDataSource.TempInputStream
An InputStream implementation that deletes the source file
once the entire stream has been read (=any of the read()
methods return -1) or when close() is called. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
mimeType
private final String mimeType
numStreams
private int numStreams
TempFileDataSource
public TempFileDataSource(File file,
String mimeType)
getContentType
public String getContentType()
- Get the supplied MIME type, if any. Otherwise call
super.getContentType().
- Specified by:
getContentType
in interface DataSource
- Overrides:
getContentType
in class FileDataSource
getInputStream
public InputStream getInputStream()
throws IOException
- Get an InputStream that deletes the source file as soon
as the end of file is reached or close() is called. If
this method is called more than once the file deletion is
disabled since it may interfere with other streams.
- Specified by:
getInputStream
in interface DataSource
- Overrides:
getInputStream
in class FileDataSource
- Throws:
IOException