1

在应用程序中,我们使用 zip4j 库来解压缩 zip 文件。

File toBeExtractedFile = new File("valid/path/to/File");
ZipFile zipFile = new ZipFile(toBeExtractedFile);
zipFile.setFileNameCharset(StandardCharsets.UTF_8.name);
zipFile.extractAll("valid/path")

使用 .zip 文件,此代码可以正常工作。但是当使用 .tar 文件完成时,这将抛出一个new ZipException("zip headers not found. probably not a zip file"); Can the zip4j library extract TAR files when given additional info or parameters or I have to use other things like a TarArchiveInputstream?

4

1 回答 1

1

不,ZIP 和 TAR 是两种不同的存档格式。您可以使用支持 TAR 格式的Apache Commons Compress 。

于 2019-01-23T12:26:30.190 回答