kdgwill kdgwill - 1 year ago 131
Java Question

How to Compress/Decompress tar.gz files in java

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).

Answer Source

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();

Similar *Archiver classes are there for archiving.

With Maven, you can use this dependency:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download