读取ZIP文件会产生“无效的LOC标头”异常 [英] Reading ZIP file gives an 'invalid LOC header' Exception
问题描述
我有一个大的zip文件,4.3G。它包含大约100k条目。
我在Linux上使用Java 1.6.0_14,Ubuntu 32位读取它,并获得以下异常。
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)
我没有任何其他ZIP文件的问题(处理它们的代码非常成熟)我已经验证我可以使用'unzip'从命令行正确解压缩zip文件。
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'.
有什么线索吗?谢谢!
推荐答案
Zip文件大小超过4GB,要求zip文件阅读器支持PKWARE的ZIP64扩展。
Zip files greater than 4GB in size, require the zip file reader to support the ZIP64 extensions by PKWARE.
在Java 6之前,这种支持在java.util.zip类中不可用,并且最近才被添加到Java 7中(不用说,这不是一个GA发布时,在撰写本文时)。
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).
参考:
- Support for ZIP64 in Java 7 has been added
这篇关于读取ZIP文件会产生“无效的LOC标头”异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!