for(int i=0; i<password.length;i++){
ZipFile zip = new ZipFile(path);
if (zip.isEncrypted()) {
zip.setPassword(password[i]);
}
try{
zip.extractAll(neweachpath);
}
catch(ZipException e)
{if (e.getCode()==ZipExceptionConstants.WRONG_PASSWORD){
//System.out.println("wrong password");
}
}
}
I use this piece of code to unzip file with password. The problem is if the zip file has many subfiles, the first one unzipped is empty,others are fine. If the zip file has one subfile, then the result is empty. Anyone knows how this happened? thanks.
ps. the iteration is just a way to try the password out