FileDocCategorySizeDatePackage
TempFile.javaAPI DocApache Poi 3.0.12122Mon Jan 01 12:39:42 GMT 2007org.apache.poi.util

TempFile

public class TempFile extends Object
Interface for creating temporary files. Collects them all into one directory.
author
Glen Stampoultzis

Fields Summary
static File
dir
static Random
rnd
Constructors Summary
Methods Summary
public static java.io.FilecreateTempFile(java.lang.String prefix, java.lang.String suffix)
Creates a temporary file. Files are collected into one directory and by default are deleted on exit from the VM. Files can be kept by defining the system property poi.keep.tmp.files.

Dont forget to close all files or it might not be possible to delete them.


                                                         
            
    
        if (dir == null)
        {
            dir = new File(System.getProperty("java.io.tmpdir"), "poifiles");
            dir.mkdir();
            if (System.getProperty("poi.keep.tmp.files") == null)
                dir.deleteOnExit();
        }

        File newFile = new File(dir, prefix + rnd.nextInt() + suffix);
        if (System.getProperty("poi.keep.tmp.files") == null)
            newFile.deleteOnExit();
        return newFile;