Can anyone show me the correct way to compress and decompress tar.gzip files in java i've been searching but the most i can find is either zip or gzip(alone).
解决方案
My favorite is plexus-archiver - see sources on GitHub.
Another option is Apache commons-compress - (see mvnrepository).
With plexus-utils, the code for unarchiving looks like this:
final TarGZipUnArchiver ua = new TarGZipUnArchiver();
ua.setSourceFile(sourceFile);
destDir.mkdirs();
ua.setDestDirectory(destDir);
ua.extract();
Similar *Archiver classes are there for archiving.
With Maven, you can use this dependency:
org.codehaus.plexus
plexus-archiver
2.2