使用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
}