简体   繁体   English

java.util.zip.ZipException:CEN标头无效(签名错误)

[英]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). 给出一个提示,它是ZIP64ZIP规范的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.

相关问题 解压缩Java中导致“ java.util.zip.ZipException”的zip文件-无效的LOC标头(错误的签名) - Unpacking zip files in Java that cause a “java.util.zip.ZipException” - invalid LOC header (bad signature) “由以下原因导致:java.util.zip.ZipException:无效的LOC标头(错误的签名)” - “Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)” java.util.zip.ZipError:无效的 CEN header(签名错误) - java.util.zip.ZipError: invalid CEN header (bad signature) Java 8 zipfile&gt; 4 GB。 ZipException:无效的CEN标头(错误的签名) - Java 8 zipfile > 4 GB . ZipException: invalid CEN header (bad signature) 不一致的 java.util.zip.ZipException:gradle 项目上的 ZipFile 无效的 LOC 标头 - Inconsistent java.util.zip.ZipException: ZipFile invalid LOC header on gradle project 原因:java.util.zip.ZipException:设置的代码长度无效 - Caused by: java.util.zip.ZipException: invalid code lengths set java.util.zip.ZipException:使用 SentenceModel 设置的代码长度无效 - java.util.zip.ZipException: invalid code lengths set with SentenceModel java.util.zip.ZipException:无效的压缩方法 - java.util.zip.ZipException: invalid compression method java.util.zip.ZipException:无效的存储块长度 - java.util.zip.ZipException: invalid stored block lengths java.util.zip.ZipException:无效的通用标志:9 - java.util.zip.ZipException: invalid general purpose flag: 9
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM