Do anyone have coding in java to extract .tar.Z files.
Assume that i am having file called home.tar.Z I need extract this file using java code, can you give any sample code.
Thanks
Do anyone have coding in java to extract .tar.Z files.
Assume that i am having file called home.tar.Z I need extract this file using java code, can you give any sample code.
Thanks
The .Z
extension is not the gzip
extension, it is from compress
.
You can launch shell scripts from Java, I'd do it like that, since I don't know any compress
library for Java. For tar/gz you could use Plexus Archiver or Apache Commons VFS.
See
Sadly it doesn't seem that any libraries cover .Z
files, so I think those links are unusable for you.
But take a look at:
This allows you to do everything with the shell commands which means you won't have to bother doing it from Java.
It is obviously late to help the OP, but for posterity, Apache commons-compress
does support *.Z.
For example
import org.apache.commons.compress.compressors.z.ZCompressorInputStream;
...
FileInputStream fin = new FileInputStream("/path/to/archive.something.Z");
BufferedInputStream in = new BufferedInputStream(fin);
ZCompressorInputStream zIn = new ZCompressorInputStream(in);
BufferedReader br = new BufferedReader(new InputStreamReader(zIn));
while (null != (content = br.readLine())) {
System.out.println(content);
}
br.close();