I try to retrieve a zip file present on the disk using FileSystems.getFileSystem
but I have an Exception:
java.nio.file.FileSystemNotFoundException at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171).
This is the code
Path path = Paths.get("/Users/Franz/Documents/plan.zip");
FileSystems.getFileSystem(URI.create("jar:" + path.toUri()));
But if i create a newFileSystem and after use getFileSystem it works :
Path path = Paths.get("/Users/Franz/Documents/plan.zip");
Map<String, String> env = new HashMap<String, String>();
env.put("create", "false");
URI uri = URI.create("jar:" + path.toUri());
FileSystems.newFileSystem(uri, env);
FileSystem fileSystem = FileSystems.getFileSystem(URI.create("jar:" + path.toUri())); // return ZipFileSystem
Path pathFile = fileSystem2.getPath("plan.docx"); // File in the zip file
Files.exists(pathFile); // returns true;
Can I have directly the ZipFileSystem
?
Thank you.