containerDir = new File(zipArchive.getParentFile(), fileName);
containerDir.mkdir();
} else {
throw new IOException("Not a zipfile!");
}
ZipFile zipFile = new ZipFile(zipArchive);
Enumeration<ZipArchiveEntry> entries = zipFile.getEntriesInPhysicalOrder();
while (entries.hasMoreElements()) {
ZipArchiveEntry currentEntry = entries.nextElement();
String entryName = currentEntry.getName();
logger.debug("Current entry: " + entryName);
try {
logger.debug(zipArchive.getParent() + "/" + currentEntry.getName());
File destFile = new File(containerDir, currentEntry.getName());
if (currentEntry.isDirectory()){
destFile.mkdir();
logger.debug("created directory: " + destFile.getAbsolutePath());
// create the parent directory structure if needed
} else {
File parentDir = destFile.getParentFile();
if (!parentDir.exists()){
parentDir.mkdir();
}
destFile.createNewFile();
logger.debug("created file: " + destFile.getAbsolutePath());
copyInputStream(zipFile.getInputStream(currentEntry),
new BufferedOutputStream(new FileOutputStream(destFile)));
unarchivedFiles.add(destFile);
logger.info("Unzipped file : " + destFile.getName());
}
} catch (Exception e){
e.printStackTrace();
logger.error("zip exception:" + e.getMessage());
break;
}
}
zipFile.close();
} catch (FileNotFoundException e) {
logger.error("file not found exception");
//e.printStackTrace();
} catch (IOException e) {