Am 15.07.2014 um 15:56 schrieb Theodore Petrosky <[email protected]>:
> 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 protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
