uk.ac.starlink.util
Class TemporaryFileDataSource
java.lang.Object
|
+--uk.ac.starlink.util.DataSource
|
+--uk.ac.starlink.util.FileDataSource
|
+--uk.ac.starlink.util.TemporaryFileDataSource
- public class TemporaryFileDataSource
- extends FileDataSource
A DataSource which stores its data in a temporary file. This can be
used to represent data which is only available to read once from an
intput stream. The stream is read when this source is constructed,
and cached in a temporary file. The temporary file is removed
when this object is finalized or when the VM is terminated normally.
Method Summary |
void |
finalize()
Deletes the temporary data file. |
URL |
getURL()
Returns null, since the data is not represented by a
persistent object. |
Methods inherited from class uk.ac.starlink.util.DataSource |
close, forceCompression, getCompression, getHybridInputStream, getInputStream, getIntro, getIntroLimit, getLength, getName, getPosition, getSystemId, makeDataSource, makeDataSource, setCompression, setIntroLimit, setName, setPosition, toString |
TemporaryFileDataSource
public TemporaryFileDataSource(InputStream baseStream,
String name)
throws IOException
- Constructs a new DataSource by reading the contents of an
input stream. The name of the source is also supplied; it does
not take the name (or URL) of the file, since that does not
represent a persistent object.
- Parameters:
baseStream
- the stream which supplies this source's dataname
- the name of the source
getURL
public URL getURL()
- Returns null, since the data is not represented by a
persistent object.
- Overrides:
getURL
in class FileDataSource
- Returns:
- a URL corresponding to this source, or null
finalize
public void finalize()
- Deletes the temporary data file.
- Overrides:
finalize
in class Object