I have a method that launches cmd
through Process
public void startCmd(){
try {
Process p = Runtime.getRuntime().exec("cmd");
BufferedReader stdInput = new BufferedReader(newInputStreamReader(p.getInputStream()));
while ((s = stdInput.readLine()) != null)
System.out.println(s);
} catch (IOException e) {
e.printStackTrace();
}
}
My task is to create a way to pass a command and based on response, pass another command. For instance:
foo
result: bar, baz
if the result is baz
, execute A
, and if A
returns C
execute D
in the same process, I need to do it all in java, the result of the whole operation will be processed further down the pipeline.