cdox.util
Class TempFiles

java.lang.Object
  extended bycdox.util.TempFiles

public class TempFiles
extends java.lang.Object

This is a utility class that takes care of some temporarily files. One gets a unique key (the temp file name) to get an input stream out of the get method ("got" it?)(yes, probably a bad one).

Version:
May 22nd 2002
Author:
Rutger Bezema, Andreas Schmitz

Constructor Summary
TempFiles()
           
 
Method Summary
static java.lang.String add(java.awt.image.BufferedImage image)
          This method adds an image as temp file.
static java.lang.String add(java.io.File f)
          This method adds a temp file.
static void add(java.lang.String key, java.io.File f)
          This method adds a temp file that has already been created.
static java.lang.String add(java.util.zip.ZipFile f, java.util.zip.ZipEntry e)
          This method adds a temp file.
static java.io.BufferedInputStream get(java.lang.String s)
          Returns the input stream for the temp file associated with the specified name.
static java.awt.image.BufferedImage getImage(java.lang.String s)
          Returns a buffered image that has previously been stored in a temp file.
static java.awt.image.BufferedImage loadImage(java.io.InputStream in)
          Reads an image out of the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TempFiles

public TempFiles()
Method Detail

add

public static void add(java.lang.String key,
                       java.io.File f)
This method adds a temp file that has already been created. Please note that f is not removed automatically, one must invoke the deleteOnExit() method before adding it here.

Parameters:
key - the temp file key.
f - the temp file.

add

public static java.lang.String add(java.io.File f)
                            throws java.io.IOException
This method adds a temp file.

Parameters:
f - the file to read the temp file from.
Returns:
a unique string identifying the resource.
Throws:
java.io.IOException - if the temporary file could not be created or the original file could not be read.

add

public static java.lang.String add(java.util.zip.ZipFile f,
                                   java.util.zip.ZipEntry e)
                            throws java.io.IOException
This method adds a temp file. The ZipFile will not be closed!

Parameters:
f - the file to read the temp file from.
e - the zip entry to use.
Returns:
a unique string identifying the resource.
Throws:
java.io.IOException - if the temporary file could not be created or the original file could not be read.

add

public static java.lang.String add(java.awt.image.BufferedImage image)
                            throws java.io.IOException
This method adds an image as temp file. This ones can then also be read with the getImage method.

Parameters:
image - the image to temporary store.
Returns:
a unique string identifying the resource.
Throws:
java.io.IOException - if the temporary file could not be created.

get

public static java.io.BufferedInputStream get(java.lang.String s)
Returns the input stream for the temp file associated with the specified name.

Parameters:
s - the key for the temp file.
Returns:
the input stream or null, if something went wrong.

getImage

public static java.awt.image.BufferedImage getImage(java.lang.String s)
Returns a buffered image that has previously been stored in a temp file.

Parameters:
s - the key for the temp file.
Returns:
the image or null, if something went wrong.

loadImage

public static java.awt.image.BufferedImage loadImage(java.io.InputStream in)
                                              throws java.io.IOException
Reads an image out of the stream. This one creates a BufferedImage of TYPE_INT_ARGB.

Parameters:
in - where to read the image.
Returns:
the image.
Throws:
java.io.IOException - if an error occurs.