java - WinZip is unable to open zipped file prepared using Apache commons compress ApI -


i have scenario zip files , folders (with sub-folders). able achieve using apache commons compress library, this post. have application uses java.util.zip library unzip file. utility not able read apache commons compress zipped folder, first zipentry null.

however when zipped file prepared using winzip, utility has no problem in unzipping it.

i tried unzip compression zip file using winzip, gives error - unable open local header "filename". idea how add local header files? checked source code ziparchiveoutputstream, writetolocalheaderfile.

any pointers issue? unzip code below:

{ file destdir = new file(destdirectory); zipinputstream zipin = new zipinputstream(new fileinputstream(zipfilepath)); zipentry entry = zipin.getnextentry();  // iterates on entries in zip file while (entry != null) {     string filepath = destdirectory + file.separator + entry.getname();     if (!entry.isdirectory()) {         // if entry file, extracts         extractfile(zipin, filepath, currentsize, totalsize);     } else {         // if entry directory, make directory         file dir = new file(filepath);         dir.mkdir();     }     zipin.closeentry();     entry = zipin.getnextentry(); } zipin.close(); } 

however able see there entries available in zip file through other ways, unfortunately cannot include new code in utility. code snippet:

zipfile zipfile =  new zipfile(new file(zipfilepath)); enumeration entries = zipfile.entries();    while(entries.hasmoreelements()) {        zipentry ze = (zipentry) entries.nextelement();        system.out.println(ze.getname());        if(!ze.isdirectory())            system.out.println("is not directory");    } 


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -