当前位置: 首页 > 工具软件 > TrueZIP > 使用案例 >

java listfiles 使用_如何在Java中使用truezip从tar中的listfiles()?

齐驰
2023-12-01

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

}

 类似资料: