Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8172846

Zip filesystem provider does not work with directory with spaces

XMLWordPrintable

    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.8.0_112"
      Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Wersja 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      When one tries to create a zip file in a path that contains spaces, using the FileSystems class, a file is not created and exception"java.nio.file.NoSuchFileException" is thrown.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Please try running the source code supplied.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A zip file is created.
      ACTUAL -
      Exception "java.nio.file.NoSuchFileException" is thrown

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.IOException;
      import java.net.URI;
      import java.net.URISyntaxException;
      import java.nio.file.FileSystem;
      import java.nio.file.FileSystems;
      import java.nio.file.Path;
      import java.nio.file.Paths;
      import java.util.Collections;

      public class Test {

          static void produceZip (Path directoryPath) throws URISyntaxException, IOException {
              Path zipPath = Paths.get("c:", "dev", "test space", "zipped.zip");
              URI uri = new URI("jar", zipPath.toUri().toString(), null);
              try (FileSystem zipfs = FileSystems.newFileSystem(uri,
                      Collections.singletonMap("create", "true"))) {
              }
          }

          public static void main(String[] args) {
              try {
                  produceZip(Paths.get("src"));
              } catch (Throwable t) {
                  System.out.println("Błąd: " + t.getMessage());
                  t.printStackTrace();
              }
          }
      }
      ---------- END SOURCE ----------

            sherman Xueming Shen
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: