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).
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
In my experience Apache Compress is much more mature than Plexus Archiver, specifically because of issues like http://jira.codehaus.org/browse/PLXCOMP-131.
I believe Apache Compress has more activity as well.
I've written a wrapper for commons-compress called jarchivelib that makes it easy to extract or compress from and into
File
objects.Example code would look like this:
To extract the contents of .tar.gz format, I successfully use apache commons-compress ('org.apache.commons:commons-compress:1.12'). Take a look at this example method:
If you are planning to compress/decompress on Linux, you can call the shell command line:
It works for me, using
GZIPInputStream
, https://www.mkyong.com/java/how-to-decompress-file-from-gzip-file/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:
Similar *Archiver classes are there for archiving.
With Maven, you can use this dependency: