Skip to content
Advertisement

Java Zip File System Provider: ReadOnly on remote drive [Windows]

I have a problem with Zip File System Provider: If the zip file is on a remote drive (mapped or not seems to be irrelevant), the virtual file system is readonly, although the file itself is not. I wrote a minimal sample code:

JavaScript

If workingDir is a local directory, everything works fine. However, if it is a (mapped) remote drive, i get:

JavaScript

Am I doing something wrong? Is it impossible? Is there a workaround?

Advertisement

Answer

I ran into the same thing and I looked at the JDK code.

Findings

In ZipFileSystem.java there are three relevant lines:

JavaScript

zfPath is a Path object. Something in the Windows FileSystem provider blocks write access to a zip archive path. Doesn’t seem like there is much to be done about that.

Workaround

What I used as a workaround was to:

  1. Create the zip archive in a temp folder
  2. Populate the zip archive
  3. Copy the temp file to the original mapped drive location

As long as the mapped drive is writable in contexts outside of the zip FileSystem, this method works.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement