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 becomes unreachable or when the VM is terminated normally.

- - ### Field Summary

    - ### Fields inherited from class uk.ac.starlink.util.DataSource

      `DEFAULT_INTRO_LIMIT, MARK_WORKAROUND_PROPERTY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TemporaryFileDataSource(java.io.InputStream baseStream, java.lang.String name)` Constructs a new DataSource by reading the contents of an input stream.
    `TemporaryFileDataSource(java.io.InputStream baseStream, java.lang.String name, java.lang.String prefix, java.lang.String suffix, java.io.File directory)` Constructs a new DataSource by reading the contents of an input stream.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.net.URL` | `getURL()` Returns `null`, since the data is not represented by a persistent object.

    - ### Methods inherited from class uk.ac.starlink.util.FileDataSource

      `getFile, getRawInputStream, getRawLength`

    - ### Methods inherited from class uk.ac.starlink.util.DataSource

      `close, forceCompression, getCompression, getHybridInputStream, getInputStream, getInputStream, getIntro, getIntroLimit, getLength, getMarkWorkaround, getName, getPosition, getSystemId, makeDataSource, makeDataSource, makeDataSource, setCompression, setIntroLimit, setMarkWorkaround, setName, setPosition, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### TemporaryFileDataSource

          public TemporaryFileDataSource(java.io.InputStream baseStream,
                                         java.lang.String name)
                                  throws java.io.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 data
        `name` - the name of the source
      Throws:
        `java.io.IOException`

    - #### TemporaryFileDataSource

          public TemporaryFileDataSource(java.io.InputStream baseStream,
                                         java.lang.String name,
                                         java.lang.String prefix,
                                         java.lang.String suffix,
                                         java.io.File directory)
                                  throws java.io.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. Using this constructor you may also supply the prefix, suffix and directory used for the temporary file see `File.createTempFile(String,String,File)`.
      Parameters:
        `baseStream` - the stream which supplies this source's data
        `name` - the name of the source
        `prefix` - the prefix string to be used in generating the file's name; must be at least three characters long
        `suffix` - the suffix string to be used in generating the file's name; may be null, in which case the suffix ".tmp" will be used
        `directory` - the directory in which the file is to be created, or null if the default temporary-file directory is to be used
      Throws:
        `java.io.IOException`

  - ### Method Detail

    - #### getURL

          public java.net.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`