java - Reading data from multiple zip files and combining them to one -


i want read data lets 4 zip files called zip1, zip2, zip3, zip4. of these zip files split 1 big zip file called "bigzip". want combine zip files 1 , compare bytes if 1 bigzip file matches size of bytes combined zip file of (zip1+zip2+zip3+zip4). getting small file size when combine size of 4 zip files. doing wrong?

here code same:

targetfilepath1, targetfilepath2, targetfilepath3, targetfilepath4 belongs path of 4 zip files. sourcefilepath path bigzip file

class test {   public static void main(string args[]) {  zipoutputstream outstream = new zipoutputstream(new fileoutputstream(sourcebigzip));              readzip(sourcefilepath, targetfilepath1);             readzip(sourcefilepath, targetfilepath2);             readzip(sourcefilepath, targetfilepath3);             readzip(sourcefilepath, targetfilepath4);   outstream.close(); }  static void readzip(string sourcebigzip, string targetfile) throws exception {     zipinputstream instream = new zipinputstream(new fileinputstream(targetfile));     byte[] buffer = new byte[1024];     int len = instream.read(buffer);     while (len != -1) {         outstream.write(buffer, 0, len);         len = instream.read(buffer);         system.out.print(len);     }      instream.close(); } } 

create zipoutputstream once , pass readzip() method, like:

public static void main(string args[]) {     zipoutputstream outstream = new zipoutputstream(new fileoutputstream(sourcefilepath));     readzip(outstream , targetfilepath1);     readzip(outstream , targetfilepath2);     readzip(outstream , targetfilepath3);     readzip(outstream , targetfilepath4); } 

then have error dealing copying data 1 zip another... need copy each file in zip file this:

static void readzip(zipoutputstream outstream, string targetfile)         throws exception {     zipinputstream instream = new zipinputstream(new fileinputstream(             targetfile));     byte[] buffer = new byte[1024];     int len = 0;      (zipentry e; (e = instream.getnextentry()) != null;) {         outstream.putnextentry(e);         while ((len = instream.read(buffer)) > 0) {             outstream.write(buffer, 0, len);         }     }     instream.close(); } 

}


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -