Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
836 views
in Technique[技术] by (71.8m points)

zip - Java Compression Library To Support Deflate64

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: 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)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...