Java ZipFileSystem attributes
<p>So I am using a code VERY similar to the following (pulled from <a href="http://fahdshariff.blogspot.com/2011/08/java-7-working-with-zip-files.html" rel="nofollow">http://fahdshariff.blogspot.com/2011/08/java-7-working-with-zip-files.html</a>):</p>

<pre><code>/**
 * Creates/updates a zip file.
 * @param zipFilename the name of the zip to create
 * @param filenames list of filename to add to the zip
 * @throws IOException
 */
public static void create(String zipFilename, String... filenames)
    throws IOException {

  try (FileSystem zipFileSystem = createZipFileSystem(zipFilename, true)) {
    final Path root = zipFileSystem.getPath("/");

    //iterate over the files we need to add
    for (String filename : filenames) {
      final Path src = Paths.get(filename);

      //add a file to the zip file system
      if(!Files.isDirectory(src)){
        final Path dest = zipFileSystem.getPath(root.toString(),
                                                src.toString());
        final Path parent = dest.getParent();
        if(Files.notExists(parent)){
          System.out.printf("Creating directory %s\n", parent);
          Files.createDirectories(parent);
        }
        Files.copy(src, dest, StandardCopyOption.REPLACE_EXISTING);
      }
      else{
        //for directories, walk the file tree
        Files.walkFileTree(src, new SimpleFileVisitor&lt;Path&gt;(){
          @Override
          public FileVisitResult visitFile(Path file,
              BasicFileAttributes attrs) throws IOException {
            final Path dest = zipFileSystem.getPath(root.toString(),
                                                    file.toString());
            Files.copy(file, dest, StandardCopyOption.REPLACE_EXISTING);
            return FileVisitResult.CONTINUE;
          }

          @Override
          public FileVisitResult preVisitDirectory(Path dir,
              BasicFileAttributes attrs) throws IOException {
            final Path dirToCreate = zipFileSystem.getPath(root.toString(),
                                                           dir.toString());
            if(Files.notExists(dirToCreate)){
              System.out.printf("Creating directory %s\n", dirToCreate);
              Files.createDirectories(dirToCreate);
            }
            return FileVisitResult.CONTINUE;
          }
        });
      }
    }
  }
}
</code></pre>

<p>When I call the Files.copy() in the visitFile() method, the src has 'rwxr-xr-x' file permissions, and the dest is successfully created. When I unzip the result, the corresponding file has only 'rw-r--r--' permissions. I tried using </p>

<pre><code>Files.copy(src, dest, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING)
</code></pre>

<p>but the file still has 'rw-r--r--' permissions... Doing a Files.create() with 'rwxr-xr-x' permissions set has the same result... Any ideas?</p>

<p>EDIT: I tried the following, but i just get an UnsupportedOperationException:</p>

<pre><code>Set&lt;PosixFilePermission&gt; permissions = PosixFilePermissions.fromString("rwxr-xr-x");
Files.setPosixFilePermissions(dest, permissions);
</code></pre>