Shitu Shitu - 7 months ago 89
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?


Using java.lang.Runtime.exec:

Runtime.exec("uncompress " + zFilePath);


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

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