• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Java File.createTempFile() ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Java File.createTempFile() ?


  • Subject: Re: Java File.createTempFile() ?
  • From: Ralf Schuchardt <email@hidden>
  • Date: Wed, 16 Jul 2014 17:52:14 +0200


Am 15.07.2014 um 15:56 schrieb Theodore Petrosky <email@hidden>:

I was rooting around on my Mac as I had just installed a new SSD and I wanted to do a clean install of a lot of stuff. I noticed  a bunch of pdfs hanging around and I wanted to find out where they were coming from.

I found them here: 

/var/folders/f1/68bl839n5vzcw6l75jgykqk40000gn/T

These pdfs are create whenever I run my app and create a pdf with ERJasperReports. They get created in ERJRUtilities.java in the method   runCompiledReportToPDFFile  it looks like:

File destFile = File.createTempFile(compiledReportName + System.currentTimeMillis(), ".pdf");

I am reading everything in Kieran’s ERJasperReports, I don’t see that the temp files are ever deleted. Did I miss something obvious? After googling around, I found a few conversations on StackOverflow all talk about temp files and methods to make sure they are deleted.

of course I could add    destFile.deleteOnExit(); before returning, but that just means the temp file will get deleted when the app exits. Or rather it gets deleted when the VM terminates normally.

Is anyone else using ERJasperReports that can confirm that these temp files are or are not being deleted?

this is the stack overflow conversation. It appears to be rather complex as the destFile is created, but needs to hang around until it has been properly downloaded.

http://stackoverflow.com/questions/16691437/when-are-java-temporary-files-deleted


Does anyone have any experience with JasperReports either your own creation, or using ERJasperReports that takes care of these pesky temp files?

Ted


I had the same problem with temp files. I simply use a wrapper class around the InputStream, created from such a file, that deletes the file on close(). Close will be called by WebObjects after reading all data for the response.

public class FileDeletingInputStream extends FilterInputStream {

    

    private final File file;

    public FileDeletingInputStream(File aFile) throws FileNotFoundException
    {
        super(new FileInputStream(aFile));
        file = aFile;
    }

    

    @Override
    public void close() throws IOException
    {
        super.close();
        if (file.isFile()) {
            file.delete();
        }
    }
}

Ralf

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Java File.createTempFile() ? (From: Theodore Petrosky <email@hidden>)

  • Prev by Date: Re: Redirect from Spring MVC application to WebObjects application
  • Next by Date: Re: Enums in D2W
  • Previous by thread: Java File.createTempFile() ?
  • Next by thread: EO*Qualifier implements equals() but not hashcode()
  • Index(es):
    • Date
    • Thread