java - Possible to determine size of file to be unzipped? -
i have following code uses zipinputstream decompress zip file target location on phone:
zipinputstream zipinputstream = new zipinputstream(new fileinputstream(sourcezipfile)); zipentry zipentry = null; while ((zipentry = zipinputstream.getnextentry()) != null) { file zipentryfile = new file(targetfolder, zipentry.getname()); // write contents of 'zipentry' 'zipentryfile' does know whether possible (using setup above or otherwise) (an estimate of) total number of files or bytes unzipped before commencing , increment progress decompression proceeds? thought zipinputstream might have gettotalentries() or similar method can't find this...
use zipentry#getsize() method. returns size of uncompressed file.
if have more 1 entry (file) inside zip file, iterate through them first (without extracting them), , add file sizes. might pretty estimate.
note, if need know exact number of bytes files occupy on disk, need know exact size of cluster in filesystem.
Comments
Post a Comment