thrau / jarchivelib

A simple archiving and compression library for Java
https://github.com/thrau/jarchivelib
Apache License 2.0
198 stars 36 forks source link

[Question] Extract a .gz file #78

Closed cldsnchz closed 5 years ago

cldsnchz commented 5 years ago

Is it possible to extract a .gz file (not .tar.gz)?

I get Unknown archive file extension .gz when call Archiver logArchiver = ArchiverFactory.createArchiver(logFile);

I tried several combinations but couldn't find a way to generate an Archiver that works for only .gz files.

thrau commented 5 years ago

Yes, it's possible to extract gzip compressed files. Unfortunately compressors aren't reconciled with the Archiver API nicely, but you can use the Compressor interface.

Compressor compressor = CompressorFactory.createCompressor(logFile)
compressor.decompress(logFile, new File("path/to/target.txt"));
cldsnchz commented 5 years ago

Perfect, worked fine. Thanks!