hi,
Does java has any api for compressing files or folders by tar and
gzip?where do i get the library(jar) for this? i seen standard java api
only provides java.util.zip classes only. But it does not have any
classes for tar and gzip. Pls give me any links where i get libraires
downloadable.
thanks,
nagesh
Thomas Kellerer - 25 Feb 2006 10:41 GMT
Nagesh wrote on 25.02.2006 11:31:
> hi,
>
[quoted text clipped - 3 lines]
> classes for tar and gzip. Pls give me any links where i get libraires
> downloadable.
The standard libraries do supply gzip support:
http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/GZIPInputStream.html
http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/GZIPOutputStream.html
at least that's what the docs say: "for reading compressed data in the GZIP format"
The Jakarta project seems to be working on tar support:
http://jakarta.apache.org/commons/sandbox/compress/
As this is obviously taken from the Ant sources, you might want to check them as
well.
A quick search in google revealed this as well:
http://www.trustice.com/java/tar/
Thomas
NOBODY - 25 Feb 2006 12:46 GMT
> Does java has any api for compressing files or folders by tar and
> gzip?where do i get the library(jar) for this? i seen standard java
> api only provides java.util.zip classes only. But it does not have any
> classes for tar and gzip. Pls give me any links where i get libraires
> downloadable.
googgled 'jtar' (and you should try do the same sometimes...)
http://www.angelfire.com/on/vkjava/
Java supports GZIP, but the GZIPInputStream cannot read multi-member gzip,
that is, a concatenation of gzips, as per the rfc 1952 (see 2.2)
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4691425
http://www.faqs.org/rfcs/rfc1952.html (see 2.2)
Beware that gzipping in java is 3x slower than the linux gzip. I resort to
runtime exec('gzip -c') while passing data to stdin and reading it back
from stdout of the spawn process...! (you can wrap it all in a simple
outputstream implementation for a nice reusability).
Roedy Green - 25 Feb 2006 23:59 GMT
>But it does not have any
>classes for tar and gzip.
GZIP yes. tar no. See http://mindprod.com/jgloss/gzip.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Nagesh - 27 Feb 2006 11:17 GMT
The following link was pretty good. Thank you very much Thomas.
http://www.trustice.com/java/tar/
nagesh