I need my program to execute a program with command line args and then return the output the program gives.
I've gotten this far, but I haven't quite figured out how to get the command line args in.
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
try {
appendLog("### Command # reboot ###");
process = new ProcessBuilder(adb.toString() + "reboot");
process.redirectErrorStream(true);
Process pr = process.start();
InputStream stream = pr.getInputStream();
InputStreamReader streamReader = new InputStreamReader(stream);
BufferedReader reader = new BufferedReader(streamReader);
String line;
int exit = -1;
while ((line = reader.readLine()) != null) {
appendLog("### ADB output # Command: reboot ###\n" + line);
exit = pr.exitValue();
if (exit == 0) {
appendLog("### Process finished # Command: reboot ###\n");
}
}
} catch (Exception ex) {
appendLog("### ERROR:\n" + ex + " ###");
appendLog("### Process finished # Command: reboot ###\n");
}
}
Any help with this matter is much appreciated. :)