Does the unpacking process work on one zip code while it doesn't work on another?

I am trying to understand why my code does not work on zip and it does not work on another.
THIS is zip unzips, and THIS zip doesnt Here is the code that I use:

String zipFile = Path + FileName; FileInputStream fin = new FileInputStream(zipFile); ZipInputStream zin = new ZipInputStream(fin); ZipEntry ze = null; while ((ze = zin.getNextEntry()) != null) { UnzipCounter++; if (ze.isDirectory()) { dirChecker(ze.getName()); } else { FileOutputStream fout = new FileOutputStream(Path + ze.getName()); while ((Unziplength = zin.read(Unzipbuffer)) > 0) { fout.write(Unzipbuffer, 0, Unziplength); } zin.closeEntry(); fout.close(); } } zin.close(); 

Can someone tell me why?

Zip doesnt work means that when it reaches the line "while ((ze = zin.getNextEntry ())! = Null) {" .. ze is always null, so it does not go into the loop, so it does not extract anything. I can open + unzip both files using WinRar ..

+1
source share
1 answer

Here is the actual error:

 java.io.EOFException at java.io.RandomAccessFile.readFully(RandomAccessFile.java:383) at gnu.java.util.zip.ZipFile$PartialInputStream.fillBuffer(ZipFile.java:647) 

It looks like your zip file is corrupted. WinRAR tends to ignore some forms of corruption.

This is a personal problem - I believe that it would be better if the tools did not do this, because it means that the person who created the zip file probably also does not know about corruption, and when you tell them they will all be similar "but it’s not, look .. it opens in [insert broken app here]."

0
source

All Articles