I have Java code doing the following:
- Create a temporary empty file with ZIP extension using
File.createTempFile()
- Delete it with
File.delete()
(we only really wanted it to generate a temp file name) - Copy a "template" ZIP file to the same path with
com.google.commons.io.ByteStreams.copy()
using a newOutputSupplier
given the same filename - Modify the ZIP archive (remove a directory) using TrueZIP 7.4.3
On a specific system, step 4 fails consistently with FsReadOnlyArchiveFileSystemException - "This is a read-only archive file system!"
(see http://java.net/projects/truezip/lists/users/archive/2011-05/message/9)
Debugging the TrueZIP code, I noticed the following:
- There is no open file handle on this file between any of the steps above, and specifically not before step 4
- Checking the same file with File.canWrite() rather than NIO returns at the exact same timing (using a debugger), it shows that it is writable
Here is what you see in the debugger expressions list:
fn => "C:/myworkdir/temp/myfile4088293380313057223tmp.zip"
java.nio.file.Files.isWritable(java.nio.file.Paths.get(fn)) => false
new java.io.File(fn).canWrite() => true
Using JDK 1.7.04
Any ideas?
new FileOutputStream()
. – Mclellan