java Extracting Zip file -


i'm looking way extract zip file. far have tried java.util.zip , org.apache.commons.compress, both gave corrupted output.

basically, input zip file contain 1 single .doc file.

java.util.zip: output corrupted. org.apache.commons.compress: output blank file, 2 mb size.

so far commercial software winrar work perfectly. there java library make use of this?

this method using java.util library:

public void extractzipnative(file filezip) {     zipinputstream zis;     stringbuilder sb;     try {         zis = new zipinputstream(new fileinputstream(filezip));         zipentry ze = zis.getnextentry();          byte[] buffer = new byte[(int) ze.getsize()];          fileoutputstream fos = new fileoutputstream(this.tempfolderpath+ze.getname());          int len;         while ((len=zis.read(buffer))>0)         {             fos.write(buffer);         }         fos.flush();         fos.close();      } catch (filenotfoundexception e) {         // todo auto-generated catch block         e.printstacktrace();     } catch (ioexception e) {         // todo auto-generated catch block         e.printstacktrace();     }      {         if (zis!=null)          {             try { zis.close();             } catch (ioexception e) {                 e.printstacktrace();             }         }     } 

}

many thanks, mike

i think input may compressed "incompatible" zip program 7zip. try investigating first if can unpacked classical winzip or such.

javas zip handling able deal zipped archives come "compatible" zip compressor.


Comments