java - what does getNextEntry() do? -
i have checked java api document, says getnextentry()
reads next zip file entry , positions stream @ origin of entry data.
what mean "reads next zip file"? why "next" ?
i have piece of code, what's point of line ze = zin.getnextentry()
?
public void unzip() { seek { fileinputstream fin = new fileinputstream(_zipfile); zipinputstream zin = new zipinputstream(fin); zipentry ze = null; while ((ze = zin.getnextentry()) != null) { log.v("decompress", "unzipping " + ze.getname()); if(ze.isdirectory()) { _dirchecker(ze.getname()); } else { fileoutputstream fout = new fileoutputstream(_location + ze.getname()); (int c = zin.read(); c != -1; c = zin.read()) { fout.write(c); } zin.closeentry(); fout.close(); } } zin.close(); } catch(exception e) { log.e("decompress", "unzip", e); } }
it reads next entry within zip file.
a zip file logically contains main other files - foo.zip
can contain files a.txt
, b.txt
. getnextentry()
moves on next file within archive.
(i've never been particularly keen on way zipinputstream
modeled using inheritance inputstream
, that's different matter.)
java zip
No comments:
Post a Comment