How can I run multiple windows system commands (using Java) in order, with the second depending on the result of the first?
Like this:
adb.exe -s emulator-5554 shell
ls
and get the list result.
This is my source code, but it is not working:
public void connectToDevice(String device) {
List<String> cmd = new ArrayList<String>();
cmd.add("adb.exe -s " + device + " shell");
cmd.add("ls");
try {
ProcessBuilder pb = new ProcessBuilder(cmd);
pb.redirectErrorStream(true);
Process process = pb.start();
} catch (IOException e) {
System.err.println(e.getMessage());
}
}