org.tranche.streams
Class DeleteFileOnExitFileInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FileInputStream
          extended by org.tranche.streams.DeleteFileOnExitFileInputStream
All Implemented Interfaces:
java.io.Closeable

public class DeleteFileOnExitFileInputStream
extends java.io.FileInputStream

A helper class that extends FileOutputStream and automatically deletes the file that it is reading once the close() method is invoked.

Author:
Jayson Falkner - jfalkner@umich.edu

Constructor Summary
DeleteFileOnExitFileInputStream(java.io.File file)
          Creates a new FileOutputStream that uses the File specified to read from.
 
Method Summary
 void close()
          Closes the parent FileOutputStream then deletes the file that was read from.
 
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

DeleteFileOnExitFileInputStream

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

Creates a new FileOutputStream that uses the File specified to read from. When this object is closed it will automatically delete the underlying file.

Parameters:
file - The File to read from.
Throws:
java.io.FileNotFoundException - If the specified file does not exist.
Method Detail

close

public void close()
           throws java.io.IOException

Closes the parent FileOutputStream then deletes the file that was read from.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.FileInputStream
Throws:
java.io.IOException - Should any IOException occur.


This code is free for use both commercially and non-commercially as stated in the project's license