The following demonstrates the issue with Zip FS and using URIs
Path zip1Path = Files.createTempFile("zip1", ".zip");
try {
Files.delete(zip1Path);
try (FileSystem zip1 = FileSystems.newFileSystem(zip1Path, Map.of("create", true))) {
Path zip2Path = zip1.getPath("zip2.zip");
try (FileSystem zip2 = FileSystems.newFileSystem(zip2Path, Map.of("create", true))) {
Path nestedFilePath = zip2.getPath("test.txt");
Path newPath = Path.of(nestedFilePath.toUri());
assert nestedFilePath.equals(newPath);
}
}
} finally {
try (Stream<Path> walk = Files.walk(zip1Path)) {
walk.sorted(Comparator.reverseOrder())
.forEach(path -> {
try {
Files.delete(path);
} catch (IOException e) {
throw new Error(e);
}
});
}
}
Path zip1Path = Files.createTempFile("zip1", ".zip");
try {
Files.delete(zip1Path);
try (FileSystem zip1 = FileSystems.newFileSystem(zip1Path, Map.of("create", true))) {
Path zip2Path = zip1.getPath("zip2.zip");
try (FileSystem zip2 = FileSystems.newFileSystem(zip2Path, Map.of("create", true))) {
Path nestedFilePath = zip2.getPath("test.txt");
Path newPath = Path.of(nestedFilePath.toUri());
assert nestedFilePath.equals(newPath);
}
}
} finally {
try (Stream<Path> walk = Files.walk(zip1Path)) {
walk.sorted(Comparator.reverseOrder())
.forEach(path -> {
try {
Files.delete(path);
} catch (IOException e) {
throw new Error(e);
}
});
}
}