2016-09-27 281 views
0

我有一个zipfile>4 GBJava 8 zipfile> 4 GB。抛出:ZipException:无效CEN头(错误签名)

这个错误与Java 1.8.0_60我发现,应该通过ZIP64是可能的。

ZipFile zipFile = new ZipFile(zippedFile); 

错误:

java.util.zip.ZipException: invalid CEN header (bad signature) 
    at java.util.zip.ZipFile.open(Native Method) 
    at java.util.zip.ZipFile.<init>(ZipFile.java:219) 

我应该得到以另一种方式使用ZIP64的条目?

+0

你可以尝试一【JAVA拉链文件系统(http://docs.oracle.com/javase/7 /docs/technotes/guides/io/fsp/zipfilesystemprovider.html) - 会很有趣。 –

+0

如果生成的zip文件格式不正确(就像你有),那么最可能的原因是你没有关闭文件。 – OldCurmudgeon

+0

@OldCurmudgeon:zip文件有效 – Bart

回答

2

我会做这样的:

FileInputStream fInput = new FileInputStream(zipFileName); 
ZipInputStream zipInput = new ZipInputStream(fInput); 
ZipEntry entry = zipInput.getNextEntry(); 

while(entry != null){ 
    String entryName = entry.getName(); 
    File file = new File(destinationFolder + File.separator + entryName); 

    // Do whatever you need with the file here 
} 

大文件跨话题:Read large files in Java

+0

这样做没有错误。谢谢。我投了票,但我还没有足够的声望,显然看不到它。 – Bart

+0

我试了一下,发现它有一些性能问题。我只是有兴趣获得zipentries。使用“新的ZipFile(文件)”我可以立即得到它们。随着流我得到的印象它加载整个文件来获取条目。你有一个想法如何继续,或者我应该打开一个新的线程? – Bart

+0

因此,您不想阅读条目中的内容,而只是查看ziped文件的列表? –

相关问题