String cmd=" D:/James/1 ASU/REU/senna-v3.0/senna/senna-win32.exe -posvbs < \"D:/James/1 ASU/REU/senna-v3.0/senna/tmp.tmp\"";
Process p2 = Runtime.getRuntime().exec(cmd);
I want to run an application and push input into it from a text file. I tried the above and the application ran, but the application complained and says "<" is not a valid command line argument.
invalid argument: < D:/James/1 ASU/REU/senna-v3.0/senna/tmp.tmp
SENNA Tagger (POS - CHK - NER - SRL) (c) Ronan Collobert 2009
How the heck do I redirect input from a file? I need to read the output stream from the application as well, which I have done with:
p2.waitFor();
char[] cbuf = new char[1024];
BufferedReader processOutput = new BufferedReader(new InputStreamReader(p2.getInputStream()));
processOutput.read(cbuf);
processOutput.read(cbuf);
System.out.println(new String(cbuf));
I do not want to run the program and send text input from stdin. I just want to run the program once, wait for it to finish and then read all of the output. The main reason for this is because the application may take an indeterminate amount of time to finish and I don't want to deal with the issue that reading will block if there is no output, etc..