tags:

views:

36

answers:

2

I have a large zip file, 4.3G. It contains about 100k entries. I am reading it using Java 1.6.0_14 on Linux, Ubuntu 32 bit, and get the following exception.

java.util.zip.ZipException: invalid LOC header (bad signature)
        at java.util.zip.ZipFile.read(Native Method)
        at java.util.zip.ZipFile.access$1200(ZipFile.java:29)
        at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:447)
        at java.util.zip.ZipFile$1.fill(ZipFile.java:230)
        at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:141)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
        at java.io.FilterInputStream.read(FilterInputStream.java:90)

I don't have issues with any other ZIP files (the code to process them is pretty mature) and I have verified that I can correctly unzip the zip file from the command line using 'unzip'.

Any clues? Thanks!

+3  A: 

Zip files greater than 4GB in size, require the zip file reader to support the ZIP64 extensions by PKWARE.

Until Java 6, this support is not available in the java.util.zip classes, and has only been recently added into Java 7 (needless to say, that this is not a GA release, at the time of writing this).

Reference:

  1. Support for ZIP64 in Java 7 has been added
Vineet Reynolds
+1  A: 

As others mentioned, files > 4GB are not supported by the ZIP standard. There's an extension called ZIP64 that adresses this issue, but it won't be supported before Java 7.

There are a number of libraries that support ZIP64, but when I last checked none of them supported streams, but relied on files instead. If that doesn't bother you, TrueZip might work fine.

If you're dealing with streams, you'll have to use temporary files.

Henning