1

I am using Ghostscript API to convert PDF to single page TIFF images.

However i am getting an error:

java.io.IOException \
   Temporary file \
   C:\DOCUME~1\LOCALS~1\Temp\ghost4j\net.sf.ghost4j.document.PDFDocument \
   cannot be deleted

This temporary file is created when Simplerenderer object renders the document and saves in List≶image>.

Can this temporary file be deleted during process run? Do i have to use some wait method for the process to complete? Is there any lock involved?

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345

1 Answers1

2

I thought it is a well-known fact amongst programmers that as long as some stream on the file is open, it is locked (at least for the Windows implementation of the JVM). So it cannot be deleted.

Did you close the stream properly before trying to delete the file?

See also

Community
  • 1
  • 1
Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
  • while this doesn't exactly answer the question, it gives good links regarding issues closing / deleting files with java – Don Cheadle Oct 24 '14 at 21:52
  • That's great if you're writing the file handler yourself. Not so great if you're dealing with a library that does it for you. – crownjewel82 Oct 07 '15 at 19:52