* @throws IOException when an exception occurs on creating the tarball
*/
public static void createFromDirectory(String sourceDirectory, String targetName) throws IOException {
FileOutputStream fileOutputStream = null;
BufferedOutputStream bufferedOutputStream = null;
GzipCompressorOutputStream gzipOutputStream = null;
TarArchiveOutputStream tarArchiveOutputStream = null;
try {
fileOutputStream = new FileOutputStream(new File(targetName));
bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
gzipOutputStream = new GzipCompressorOutputStream(bufferedOutputStream);
tarArchiveOutputStream = new TarArchiveOutputStream(gzipOutputStream);
addFilesInDirectory(tarArchiveOutputStream, sourceDirectory);
} finally {
if (tarArchiveOutputStream != null) {
tarArchiveOutputStream.finish();
}
if (tarArchiveOutputStream != null) {
tarArchiveOutputStream.close();
}
if (gzipOutputStream != null) {
gzipOutputStream.close();
}
if (bufferedOutputStream != null) {
bufferedOutputStream.close();
}
if (fileOutputStream != null) {