Java压缩库支持Deflate64

寻找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: unsupported feature method ‘ENHANCED_DEFLATED’ used in entry test.docx
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的zip库,或者可能与deflate64压缩方法一起使用?

最佳答案 在2018年2月,Apache发布了 Compress v1.16,其中包括对ENHANCED_DEFLATED的支持,即.的Deflate64.我需要这种支持,发现它似乎有效.

点赞