如何使用Java中的truezip从tar中的jar列表文件()?

Tom*_*Tom 1 java jar tar truezip

我试图列出tar中的所有文件,包括jar中的文件.

如何在Java或其他api中使用truezip来完成此操作?

谢谢

Chr*_*rle 5

使用TrueZIP 7,你可以使用这样的东西:

public static void main(String args[]) throws IOException {
    // Remember to set to add the following dependencies to the class path:
    // Compile time artifactId(s): truezip-file
    // Run time artifactId(s): truezip-kernel, truezip-driver-file, truezip-driver-tar, truezip-driver-zip
    TFile.setDefaultArchiveDetector(new TDefaultArchiveDetector("tar|zip"));
    search(new TFile(args[0])); // e.g. "my.tar" or "my.zip"
    TFile.umount(); // commit changes
}

private void search(TFile entry) throws IOException {
    if (entry.isDirectory()) {
        for (TFile member : dir.listFiles())
            search(member);
    } else if (entry.isFile()) {
        // [do something with entry]
    } // else is special file or non-existent
}
Run Code Online (Sandbox Code Playgroud)