throws IOException {
FileOutputStream out = null;
try {
out = new FileOutputStream(new File(parentDir, outputFile));
TarArchiveOutputStream tOut = new TarArchiveOutputStream(
new GzipCompressorOutputStream(new BufferedOutputStream(out)));
for (int i = 0; i < inputFiles.length; i++) {
File f = new File(parentDir, inputFiles[i]);
TarArchiveEntry tarEntry = new TarArchiveEntry(f, f.getName());
tOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
tOut.putArchiveEntry(tarEntry);
FileInputStream input = new FileInputStream(f);
try {
IOUtils.copy(input, tOut); // copy with 8K buffer, not close
} finally {
input.close();
}
tOut.closeArchiveEntry();
}
tOut.close(); // finishes inside
} finally {
// TarArchiveOutputStream seemed not to close files properly in error situation
org.apache.hadoop.io.IOUtils.closeStream(out);
}
}