1

I'm having this error with java 1.8.0_60 on a zipfile > 4 GB

I found that should be possible through zip64.

ZipFile zipFile = new ZipFile(zippedFile);

Error :

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)

Should I get the entries in another way to use zip64 ?

Nicolas Filotto
  • 43,537
  • 11
  • 94
  • 122
Bart
  • 11
  • 1
  • 2

1 Answers1

5

I would do like this:

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
}

Cross topic for large files : Read large files in Java

Community
  • 1
  • 1
Simon PA
  • 748
  • 13
  • 26
  • This did it without error. Thanks. I voted up but I don't have enough reputation yet to see it apparently. – Bart Sep 27 '16 at 12:41
  • I tried it further and found some performance issues with it. I'm just interested in getting the zipentries. With "new ZipFile(file)" I'm getting them instantly. With the stream I get the impression it loads the entire file to get the entries. Do you have an idea how to proceed or should I open a new thread? – Bart Sep 28 '16 at 12:23
  • So you don't want to read what's inside the entries but just a list of the ziped files ? – Simon PA Sep 28 '16 at 12:33
  • Right, first I have to know the entry's name before doing something with it. Afterwards I make a stream with some of the entries and pass them to the database. – Bart Sep 28 '16 at 12:54