Java inclides built in function for handling bot zipped and gziped libraries.
http://docs.oracle.com/javase/6/docs/api/java/util/zip/package-summary.html.
This can be used turn your .tgz
into a regular .tar
without much trouble. And no you cannot treat .tgz
as regular zips. They are first achived in a tar and then compressed with gzip. Even if you gunzip it, you will still need to unpack the tar archive to get any of the file out of it.
Handling tar files is a bit more difficult. This previous question might help :
How do I extract a tar file in Java?
From these solutions I strongly recommend the apache commons solution :
http://commons.apache.org/vfs/filesystems.html
It will allow you to read from your tar as if it were a filesystem without doing any writes to your hard drive. You will have to know what you're looking for before you go in to it, but i doubt that will hinder you much