ExecAndPrintpublic class ExecAndPrint extends Object ExecAndPrint runs a program using Runtime.exec(),
read the program's output, and returns its exit status. |
Fields Summary |
---|
protected static Runtime | rNeed a Runtime object for any of these methods |
Methods Summary |
---|
public static int | run(java.lang.String cmd)Run the command given as a String, printing its output to System.out
return run(cmd, new OutputStreamWriter(System.out));
| public static int | run(java.lang.String cmd, java.io.Writer out)Run the command given as a String, print its output to "out"
String line;
Process p = r.exec(cmd);
FileIO.copyFile(new InputStreamReader(p.getInputStream()), out, true);
try {
p.waitFor(); // wait for process to complete
} catch (InterruptedException e) {
return -1;
}
return p.exitValue();
| public static int | run(java.lang.String[] cmd)Run the command given as a String[], print its output to System.out
return run(cmd, new OutputStreamWriter(System.out));
| public static int | run(java.lang.String[] cmd, java.io.Writer out)Run the command given as a String[], print its output to "out"
String line;
Process p = r.exec(cmd);
FileIO.copyFile(new InputStreamReader(p.getInputStream()), out, true);
try {
p.waitFor(); // wait for process to complete
} catch (InterruptedException e) {
return -1;
}
return p.exitValue();
|
|