Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.util.zip.ZipException: too many entries in ZIP file

I am trying to write a Java class to extract a large zip file containing ~74000 XML files. I get the following exception when attempting to unzip it utilizing the java zip library:

java.util.zip.ZipException: too many entries in ZIP file

Unfortunately due to requirements of the project I can not get the zip broken down before it gets to me, and the unzipping process has to be automated (no manual steps). Is there any way to get around this limitation utilizing java.util.zip or with some 3rd party Java zip library?

Thanks.

like image 404
Andrew Avatar asked Jan 27 '09 15:01

Andrew


2 Answers

Using ZipInputStream instead of ZipFile should probably do it.

like image 88
Tom Hawtin - tackline Avatar answered Nov 10 '22 12:11

Tom Hawtin - tackline


Using apache IOUtils:

FileInputStream fin = new FileInputStream(zip);
ZipInputStream zin = new ZipInputStream(fin);
ZipEntry ze = null;

while ((ze = zin.getNextEntry()) != null) {
    FileOutputStream fout = new FileOutputStream(new File(
                    outputDirectory, ze.getName()));

    IOUtils.copy(zin, fout);

    IOUtils.closeQuietly(fout);
    zin.closeEntry();
}

IOUtils.closeQuietly(zin);
like image 28
Andrew Avatar answered Nov 10 '22 10:11

Andrew