I am trying to develop a class that reads the standard output of an external program (using an instance of Process, Runtime.getRuntime (). Exec (cmdLine, env, dir)). The program accepts user inputs during the process and will not work until a valid input is specified; this seems to cause the problem in the way I try to read its output:
egm.execute(); // run external the program with specified arguments BufferedInputStream stdout = new BufferedInputStream(egm.getInputStream()); BufferedInputStream stderr = new BufferedInputStream(egm.getErrorStream()); BufferedOutputStream stdin = new BufferedOutputStream(egm.getOutputStream()); int c; //standard output input stream int e; //standadr error input stream while((c=stdout.read()) != -1) //<-- the Java class stops here, waiting for input? { egm.processStdOutStream((char)c); } while((e=stderr.read()) != -1) { egm.processStdErrStream((char)e); } //...
How can I fix this so that the program accepts a valid input and continues? Any help in solving this problem would be great!
Lawrence park
source share