edu.ucsb.nceas.metacat.util

## Class DeleteOnCloseFileInputStream

- java.lang.Object
- - java.io.InputStream
  - - java.io.FileInputStream
    - - edu.ucsb.nceas.metacat.util.DeleteOnCloseFileInputStream

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

      public class DeleteOnCloseFileInputStream
      extends java.io.FileInputStream

  Extension of FileInputSteam that deletes the sourcefile when the InputStream is closed. Should typically be used with temporary files when a more immediate deletion should be performed than is offered by the File.deleteOnExit() method.
  Author:
    leinfelder

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DeleteOnCloseFileInputStream(java.io.File file)`
    `DeleteOnCloseFileInputStream(java.lang.String name)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Delete the file when the InputStream is closed
    `java.io.File` | `getFile()` Allow access to the underlying file - careful!

    - ### Methods inherited from class java.io.FileInputStream

      `available, finalize, getChannel, getFD, read, read, read, skip`

    - ### Methods inherited from class java.io.InputStream

      `mark, markSupported, reset`

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

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

- - ### Constructor Detail

    - #### DeleteOnCloseFileInputStream

          public DeleteOnCloseFileInputStream(java.lang.String name)
                                       throws java.io.FileNotFoundException

      Throws:
        `java.io.FileNotFoundException`

    - #### DeleteOnCloseFileInputStream

          public DeleteOnCloseFileInputStream(java.io.File file)
                                       throws java.io.FileNotFoundException

      Throws:
        `java.io.FileNotFoundException`

  - ### Method Detail

    - #### getFile

          public java.io.File getFile()

      Allow access to the underlying file - careful!
      Returns:

    - #### close

          public void close()
                     throws java.io.IOException

      Delete the file when the InputStream is closed
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Overrides:
        `close` in class `java.io.FileInputStream`
      Throws:
        `java.io.IOException`

Copyright © 2020 Regents of the University of California. All Rights Reserved.