zip4j icon indicating copy to clipboard operation
zip4j copied to clipboard

net.lingala.zip4j.exception.ZipException: Reached end of entry, but crc verification failed for test.txt

Open thePK opened this issue 2 years ago • 1 comments

For the encrypted compressed zip file, is it supported to use zinInputstream to decompress it directly? Below is my test code and maven dependency, I received the following error. But the same code will work fine for an unencrypted zip package.

maven dependency: <groupId>net.lingala.zip4j</groupId> <artifactId>zip4j</artifactId> 2.9.1

test code: public static void main(String[] args) { String srcPath = "E:\test1.zip"; try { ZipInputStream zis = new ZipInputStream(new FileInputStream(srcPath), "123".toCharArray()); LocalFileHeader nextEntry = zis.getNextEntry(); while (Objects.nonNull(nextEntry)) { String fileName = nextEntry.getFileName(); if (!nextEntry.isDirectory()) { log.info("entry name {}", fileName); } nextEntry = zis.getNextEntry(); } } catch (IOException e) { e.printStackTrace(); } }

Error reported: net.lingala.zip4j.exception.ZipException: Reached end of entry, but crc verification failed for test.txt

thePK avatar Aug 29 '23 07:08 thePK

Sorry about the format before.

For the encrypted compressed zip file, is it supported to use zinInputstream to decompress it directly? Below is my test code and maven dependency, I received the following error. But the same code will work fine for an unencrypted zip package.

maven dependency:

<dependency>
            <groupId>net.lingala.zip4j</groupId>
            <artifactId>zip4j</artifactId>
            <version>2.9.1</version>
        </dependency>

test code:

public static void main(String[] args) {
        String srcPath = "E:\\test1.zip";
        try {
            ZipInputStream zis = new ZipInputStream(new FileInputStream(srcPath), "123".toCharArray());
            LocalFileHeader nextEntry = zis.getNextEntry();
            while (Objects.nonNull(nextEntry)) {
                String fileName = nextEntry.getFileName();
                if (!nextEntry.isDirectory()) {
                    log.info("entry name {}", fileName);
                }
                nextEntry = zis.getNextEntry();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

Error reported:

net.lingala.zip4j.exception.ZipException: Reached end of entry, but crc verification failed for test.txt

thePK avatar Aug 29 '23 07:08 thePK