I use zip4j to unzip zip packages which are safed by a password (AES-256). My problem is not, that the code is not working, rather that it doen't throw any error when the password doesn't match with the actual on the .zip.
the .zip has a password with 123 and for zip4j I set the password 123456789. So he is not able to extract all. I expect an Error or any message, that it could not extract. The actual case is, he doesn't extract it but no exception or error message, nothing.
Any Idea how I can check if the extraction was successful?
protected void unpackZip(String destinationPath, String archivePath) throws InterruptedException {
int onChange = 0;
try {
ZipFile zipFile = new ZipFile( archivePath );
zipFile.setRunInThread( true );
if (zipFile.isEncrypted()) {
zipFile.setPassword( "123456789");
}
zipFile.extractAll( destinationPath );
// http://www.lingala.net/zip4j/forum/index.php?topic=68.0
ProgressMonitor progressMonitor = zipFile.getProgressMonitor();
while (progressMonitor.getState() == ProgressMonitor.STATE_BUSY) {
// To get the percentage done
if (onChange != progressMonitor.getPercentDone()) {
onChange = progressMonitor.getPercentDone();
sendWebStatusUiMessage( "Extracted : " + onChange + "% ", "update" );
}
try {
Thread.sleep( 1000 );
} catch (Exception e) {
}
}
} catch (ZipException e) {
e.printStackTrace();
}
}