Java OutputStream read() works, read(buffer) creates error -
i'm trying create encrypted zip file using library @ https://bitbucket.org/matulic/ziputils/overview. described @ http://blog.alutam.com/2012/03/31/new-library-for-reading-and-writing-zip-files-in-java, used read() read each byte , works without mistakes. when tried use buffer (which believe more efficient), file has error. code used below:
fileinputstream src = new fileinputstream("zip_file_path"); zipencryptoutputstream dest = new zipencryptoutputstream(new fileoutputstream("encrypted_file_path"), "password"); byte[] buffer = new byte[1024]; int count = 0; while ((count = src.read(buffer)) != -1) { dest.write(buffer, 0, count); } dest.close(); src.close(); when unzip file winrar, crc error shown (when use read(), doesn't happen). interesting thing note in failed file, in file properties file size of encrypted file less original file size on disk property same. might wrong here?
Comments
Post a Comment