Shitu Shitu - 3 months ago 22
Java Question

Uncompress .Z file in unix using java

I have a .Z file present on unix box. Is there any way to call unix uncompress command from java?

Answer

Using java.lang.Runtime.exec:

Runtime.exec("uncompress " + zFilePath);

UPDATE

Accoridng to the documentation, ProcessBuilder.start() is preferred.

ProcessBuilder pb = new ProcessBuilder("uncompress", zFilePath);
Process p = pb.start();
// p.waitFor();