private TarUtil() {
}
public static void untar(File source, File target, Log logger) {
TarInputStream tarInput = null;
TarEntry entry;
OutputStream output = null;
try {
tarInput = new TarInputStream(new FileInputStream(source));
entry = tarInput.getNextEntry();
while (entry != null) {
File outputFile = new File(target.getCanonicalPath() + File.separator + entry.getName());
if (entry.isDirectory()) {
logger.debug("creating dir at: " + outputFile.getCanonicalPath());
outputFile.mkdirs();
} else {
logger.debug("creating file at: " + outputFile.getCanonicalPath());
output = new FileOutputStream(outputFile);
IOUtils.copy(tarInput, output);
output.flush();
output.close();
}
entry = tarInput.getNextEntry();
}
} catch (IOException exception) {
throw new IllegalStateException(exception);
} finally {
IOUtils.closeQuietly(tarInput);