I am now on a linux machine. I have a Java program which would run some linux command, for example ps
, top
, list
or free -m
.
The way to run a command in Java is as follows:
Process p = Runtime.getRuntime().exec("free -m");
How could I collect the output by Java program? I need to process the data in the output.