Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

java - Reading ZIP file gives an 'invalid LOC header' Exception

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!

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...