[英]java.util.zip.ZipException: invalid CEN header (bad signature)
I'm getting this error when doing this (relatively simple) piece of code: 在执行此(相对简单的)代码时,我收到此错误:
ZipFile zf = new ZipFile(fn);
Enumeration<? extends ZipEntry> eze = zf.entries();
while (eze.hasMoreElements()) {
ZipEntry ze = eze.nextElement();
System.out.println(ze.getName());
}
zf.close();
Actually. 其实。 Interestingly enough, I get it on java-sun-6u32 and java-1.6.0-openjdk-amd64, but java-sun-7u4 succeeds.
有趣的是,我在java-sun-6u32和java-1.6.0-openjdk-amd64上得到它,但是java-sun-7u4成功了。 unzip itself seems to handle it fine.
解压缩本身似乎处理得很好。 I'm guessing that means that these zipfiles are perhaps created by some newer version of zip that java 7 understands, but that previous versions do not.
我猜这意味着这些zip文件可能是由java 7理解的一些较新版本的zip创建的,但之前的版本没有。 But, any insight would be appreciated.
但是,任何见解都将受到赞赏。 Also, since in production I don't really have the option of using java 7, any way of making earlier versions of java understand this new version of zip (if that in fact is what the problem is, of course.)
此外,由于在生产中我真的没有使用Java 7的选项,使早期版本的Java的任何方式理解拉链的这个新版本(如果这其实是什么问题,当然)。
Thanks! 谢谢!
7z l -slt
output provided in your comment is quite useful: 您的评论中提供的
7z l -slt
输出非常有用:
Type = zip 64-bit
Type = zip 64位
gives a hint, that it's ZIP64 (version 4.5 of ZIP specification). 给出一个提示,它是ZIP64 ( ZIP规范的4.5版本)。 However, though Java7 supports it, this support is not backported to Java6 at the moment and you will have to resort to external library such as Apache Compress .
但是,尽管Java7支持它,但此支持目前还没有向后移植到Java6 ,您将不得不求助于外部库,例如Apache Compress 。
PS For reference, file test.zip
would output something like PS作为参考,
file test.zip
会输出类似的东西
test.zip: Zip archive data, at least v4.5 to extract
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.