01: /******************************************************************************
02: * TempFileInputStream.java
03: * ****************************************************************************/package org.openlaszlo.utils;
04:
05: import java.io.FileInputStream;
06: import java.io.FileNotFoundException;
07: import java.io.File;
08: import java.io.IOException;
09:
10: /**
11: * A FileInputStream that deletes the underlying file when the stream
12: * is closed.
13: *
14: * @author <a href="mailto:bloch@laszlosystems.com">Eric Bloch</a>
15: */
16: public class TempFileInputStream extends FileInputStream {
17:
18: private final File mFile;
19:
20: /**
21: * Construct a stream that will delete this file
22: * when the stream is closed
23: * @param f the input file
24: */
25: public TempFileInputStream(File f) throws FileNotFoundException {
26: super (f);
27: mFile = f;
28: }
29:
30: /**
31: * close the stream and delete the file
32: */
33: public void close() throws IOException {
34:
35: try {
36: super.close();
37: } finally {
38: mFile.delete();
39: }
40: }
41: }
|