KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openlaszlo > utils > TempFileInputStream


1 /******************************************************************************
2  * TempFileInputStream.java
3  * ****************************************************************************/

4
5 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
6 * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
7 * Use is subject to license terms. *
8 * J_LZ_COPYRIGHT_END *********************************************************/

9
10 package org.openlaszlo.utils;
11
12 import java.io.FileInputStream JavaDoc;
13 import java.io.FileNotFoundException JavaDoc;
14 import java.io.File JavaDoc;
15 import java.io.IOException JavaDoc;
16
17 /**
18  * A FileInputStream that deletes the underlying file when the stream
19  * is closed.
20  *
21  * @author <a HREF="mailto:bloch@laszlosystems.com">Eric Bloch</a>
22  */

23 public class TempFileInputStream extends FileInputStream JavaDoc {
24
25     private final File JavaDoc mFile;
26
27     /**
28      * Construct a stream that will delete this file
29      * when the stream is closed
30      * @param f the input file
31      */

32     public TempFileInputStream(File JavaDoc f) throws FileNotFoundException JavaDoc {
33         super(f);
34         mFile = f;
35     }
36
37     /**
38      * close the stream and delete the file
39      */

40     public void close() throws IOException JavaDoc {
41
42         try {
43             super.close();
44         } finally {
45             mFile.delete();
46         }
47     }
48 }
49
Popular Tags