* extract .tar.gz file.
*/
private static void extractTargz(String fname, String targetDir, boolean removeSourceFile)
throws Exception
{
Tar app = new Tar();
try
{
makeDir(targetDir);
File fsrc = new File(fname);
app.open(fsrc, "r:gz");
//String dbname = extractName(fname);
//String targetDirAndDB = FilenameUtils.concat(targetDir,dbname);
//app.extract(targetDirAndDB);
app.extract(targetDir);
//for saving the disk space, truncate file size to zero but
//reserve the "date of last modified" as the tag.
truncate(fsrc);
if (removeSourceFile)
fsrc.delete();
}
finally
{
app.close();
}
}