Java压缩库支持Deflate64

4
寻找一款替代 Apache Commons Compress(https://commons.apache.org/proper/commons-compress/)的 Java 压缩库。当尝试读取使用“ENHANCED_DEFLATED”(即 deflate64)压缩的 zip 条目时,Commons Compress 会抛出错误。以下是一个抛出异常的示例摘录。
public void doRecurseZip(File inputFile)
        throws IOException{
    ZipFile srcZip = null;
    srcZip = new ZipFile(inputFile);

    final Enumeration<ZipArchiveEntry> entries = srcZip.getEntries();
    while (entries.hasMoreElements()) {
        final ZipArchiveEntry srcEntry = entries.nextElement();
        String entryFilename = srcEntry.getName();
        String entryMimetype = "application/octet-stream";
        boolean canRead = srcZip.canReadEntryData(srcEntry);
        InputStream zipStream = srcZip.getInputStream(srcEntry);
        zipStream.close();
    }
    srcZip.close();
}

以下是堆栈跟踪的相关部分:
org.apache.commons.compress.archivers.zip.UnsupportedZipFeatureException: 不支持在条目 test.docx 中使用增强压缩方法“ENHANCED_DEFLATED”。 at org.apache.commons.compress.archivers.zip.ZipUtil.checkRequestedFeatures(ZipUtil.java:357) at org.apache.commons.compress.archivers.zip.ZipFile.getInputStream(ZipFile.java:404) at ZippingAround.doRecurseZip(ZippingAround.java:23)
有没有人知道其他可以替换Commons Compress或与其一起使用Deflate64压缩方法的zip库?
3个回答

1

2018年2月,Apache发布了Compress v1.16,其中包括对ENHANCED_DEFLATEDDeflate64的支持。我需要这种支持,并发现它似乎可以正常工作。


0

zlib在contrib/infback9目录中提供了一个Deflate64解压缩器(使用C语言编写)。您需要将其集成到您的zip解码器中。


0

7zip-javabinding 库使用 JNI 封装了支持 Deflate64 的 7zip。它提供了特定于平台的解决方案,或者如果您愿意,它们还提供了一个 all-platforms 解决方案。

这些库可以在 Maven Central 上获取。

如果有人找到了纯 Java 解决方案,请发布另一个答案!:-)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接