ethauvin
04/11/2017, 5:49 AM/**
* Extract the zip file in ~/.kobalt/wrapper/dist/$version
*/
private void extractZipFile(Path localZipFile, String zipOutputDir) throws IOException {
log(2, "Extracting " + localZipFile);
try (ZipFile zipFile = new ZipFile(localZipFile.toFile())) {
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
Path entryPath = Paths.get(zipOutputDir, entry.getName());
if (entry.isDirectory()) {
Files.createDirectories(entryPath);
} else {
log(2, " Writing " + entry.getName() + " to " + entryPath);
try {
Files.createDirectories(entryPath.getParent());
Files.copy(zipFile.getInputStream(entry), entryPath, StandardCopyOption.REPLACE_EXISTING);
} catch (FileSystemException ex) {
log(2, "Couldn't copy to " + entryPath);
}
}
}
}
}