Shitu Shitu - 5 months ago 43
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();