31381

Unzip process works on one zip while it doesnt on another?

Question:

I've been trying to understand why my code doesnt work on a zip and it doesnt on another..<br /><a href="https://www.box.net/shared/static/ot225gfdmebttm76i6fj.zip" rel="nofollow">THIS</a> zip unzips , and <a href="http://dl.dropbox.com/u/18331007/QuranReaders/hosari/1.zip" rel="nofollow">THIS</a> zip doesnt Here is the code 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 anyone tell me why?

The zip doesnt work means that when it reaches the line "while ((ze = zin.getNextEntry()) != null) {".. ze is always null so it doesnt enter the loop so it doesnt extract anything.. I can open+unzip both files with WinRar..

Answer1:

Here's 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)

Looks like your zip file is corrupt. WinRAR tends to ignore some kinds of corruption.

This is a personal gripe of mine - I believe it would be better if tools didn't do that sort of thing, because it means that whoever created the zip file probably doesn't know about the corruption either, and when you tell them, they will be all like, "but it isn't, look .. it opens in [insert broken app here]."

Recommend

  • could not synchronize database state with session error while saving in groovy
  • Sql array only showing first result
  • Java PipedInputStream PipedOutputStream Size limitation
  • out of memory error in file manager
  • How to go from spring mvc multipartfile into zipinputstream
  • List of files inside a zip folder and its subfolder
  • Convert csv file to pipe delimited file in Python
  • marking duplicates in a csv file
  • How can I run a dotnet application in the background using sudo on Linux?
  • Getting the full path of a DirectoryEntry
  • Reading picture from byte array
  • Java android delete File
  • Java Code for writing Long Array to file [closed]
  • IIS Url Rewrite not working with nested WP installs
  • Getting error CreateListFromArrayLike called on non-object when trying to use .apply()
  • Help! unexpected java.lang.ArrayIndexOutOfBoundsException when using ByteArrayInputStream
  • How to implement file watcher to Watch multiple directories
  • Using fs.readdir and fs.statSync returns ENOENT, no such file or directory error
  • How to get html5Mode application to be root relative instead of server root relative
  • Android: isDirectory() always returning true
  • Write a file in SDcard in Android
  • Help refreshing list with notifyDataSetChanged()
  • how to get file name from the server request?
  • jfilechooser how to hide full path in folder name in DIRECTORIES_ONLY mode
  • How to create table in ms word doc with rowspan and colspan using apache POI?
  • Why can't I catch EJB exceptions?
  • Problem serializing DecimalFormatSymbols in 2.3.4
  • Issue with static code in Android
  • Where does the file get saved using “File file = new file(filename)” in Android
  • Android mkdirs() sdcard do not work
  • Getting error java.io.FileNotFoundException (log4j log file) at the time of publish project on cloud
  • Problem with rejecting incoming call
  • Extract zip entries to another Zip file
  • copying resource to sdcard gives a damaged file in android
  • Exception “firebase.functions() takes … no argument …” when specifying a region for a Cloud Function
  • How to make a tree having multiple type of nodes and each node can have multiple child nodes in java
  • Linker errors when using intrinsic function via function pointer
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • LevelDB C iterator
  • How can i traverse a binary tree from right to left in java?