Java 8文件系统访问压缩在另一个zip中的zip包中的文件

kov*_*vko 5 java filesystems zip java.nio.file

我想问是否可以访问和修改压缩在另一个 zip 包中的 zip 文件内的文本文件。

我知道我可以像这样使用 Java.nio FileSysten 访问该文件吗?在此示例中读取“sample.txt”文件中的所有行。

   FileSystem fileSystem = FileSystems.newFileSystem(new URI("jar:file", "sample/path/to/zipfile/main.zip", null), new HashMap<>());
   readAllLines("sample.txt");
Run Code Online (Sandbox Code Playgroud)

在哪里

   public List<String> readAllLines(String fileName) {
    List<String> file = new ArrayList<>();
    Path rootDir = fileSystem.getRootDirectories().iterator().next();

    try (DirectoryStream<Path> files = Files.newDirectoryStream(rootDir,
            entry -> entry.toString().equalsIgnoreCase("/" + fileName))) {
        Path path = files.iterator().next();
        file = Files.readAllLines(path, Charset.forName("ISO-8859-1"));
    } catch (NoSuchElementException | IOException e) {
        e.printStackTrace();
    }

    return file;
}
Run Code Online (Sandbox Code Playgroud)

我想问一下,如果这个“sample.txt”文件位于 2 个 zip 包中,是否也可以读取它。像 mainzip.zip/sample.zip/sample.txt

     mainzip.zip
     |
     |-sample.zip
       |
       |-sample.txt
     |-another.zip
Run Code Online (Sandbox Code Playgroud)

当然,我现在想要解压 mainzip.zip。

感谢您的任何提示