Java压缩库支持Deflate64 [英] Java Compression Library To Support Deflate64

查看:300
本文介绍了Java压缩库支持Deflate64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找Apache Commons Compress的替代压缩Java库( https://commons.apache .org/proper/commons-compress/).尝试读取使用deflate64的"ENHANCED_DEFLATED"压缩的zip条目时,Commons Compress引发错误.这是引发异常的示例摘录.

Looking for an alternative compression java library to Apache Commons Compress (https://commons.apache.org/proper/commons-compress/). Commons Compress throws an error when trying to read a zip entry that was compressed using "ENHANCED_DEFLATED" which is deflate64. Here is sample excerpt that throws the exception.

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();
}

这是堆栈跟踪的相关部分:

Here is the relevant part of the stack trace:

org.apache.commons.compress.archivers.zip.UnsupportedZipFeatureException:条目test.docx中使用的不受支持的功能方法"ENHANCED_DEFLATED" 在org.apache.commons.compress.archivers.zip.ZipUtil.checkRequestedFeatures(ZipUtil.java:357) 在org.apache.commons.compress.archivers.zip.ZipFile.getInputStream(ZipFile.java:404) 在ZippingAround.doRecurseZip(ZippingAround.java:23)

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压缩方法吗?

Does anyone know of another zip library that could replace Commons Compress, or possibly work in conjunction with it for the deflate64 compression method?

推荐答案

2018年2月,Apache发布了

In February 2018, Apache released Compress v1.16 which includes support for ENHANCED_DEFLATED, ie. Deflate64. I needed this support and found that it seems to work.

这篇关于Java压缩库支持Deflate64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆