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");
}
}
}
我使用这段代码用密码解压缩文件。问题是如果 zip 文件有很多子文件,解压缩的第一个是空的,其他的都很好。如果 zip 文件有一个子文件,则结果为空。有谁知道这是怎么回事?谢谢。
附言。迭代只是尝试密码的一种方式