Zip file with password not opening

xeon

New Member
I have to create one new zip file and put the files into that.Once i put those files,i have to set password for the zip file. the code is running file.But when i try to open the zip file ,i am getting this error.Extracting to "C:\Users\Nirmal\AppData\Local\Temp\wzdcbd\"Use Path: yes Overlay Files: yesCentral and local directory mismatch for file "f:/Report.txt" (general purpose flags - local: 1 hex central: 0 hex).Local and central GPFlags values don't match.Please help in this\[code\]import java.io.*;import java.util.zip.*;import com.chilkatsoft.CkZip;public class ZipTest { static { try { System.loadLibrary("chilkat"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load.\n" + e); System.exit(1); } } static final int BUFFER = 2048; public static void main (String argv[]) { try { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); BufferedInputStream origin = null; System.out.println(System.getProperty("sun.arch.data.model")); System.out.println("Enter Zip file name :"); String zipName=br.readLine(); FileOutputStream dest = new FileOutputStream("f:\\"+zipName+".zip"); ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest)); //out.setMethod(ZipOutputStream.DEFLATED); byte data[] = new byte[BUFFER]; String enter; do { System.out.println("Enter filename with path and extension :"); String file1= "f:\\"+br.readLine(); // String file1="f:/jxltest.xls"; FileInputStream fi = new FileInputStream(file1); origin = new BufferedInputStream(fi, BUFFER); ZipEntry entry = new ZipEntry(file1); out.putNextEntry(entry); int count; while((count = origin.read(data, 0,BUFFER)) != -1) { out.write(data, 0, count); } origin.close(); System.out.println("Want to create another file: Y/N"); enter = br.readLine(); }while(enter.equals("Y") || enter.equals("y")); out.close(); System.out.println("Zip folder created"); //Zip file password protection CkZip zip = new CkZip(); boolean success; // Any string unlocks the component for the 1st 30-days. success = zip.UnlockComponent("Anything for 30-day trial"); if (success != true) { System.out.println(zip.lastErrorText()); return; } success = zip.OpenZip("f:/"+zipName+".zip"); if (success != true) { System.out.println(zip.lastErrorText()); return; } // Set a password and indicate that password protection // should be used when writing the .zip zip.put_EncryptPassword("secret"); zip.put_PasswordProtect(true); // Write the zip (overwrites test.zip) success = zip.WriteZipAndClose(); if (success != true) { System.out.println(zip.lastErrorText()); return; } System.out.println("Zip Re-Written with Password Protection!"); } catch(Exception e) { e.printStackTrace(); } }}\[/code\]
 
Top