java runtime.getruntime() getting output from executing a command line program
<p>I am using the runtime to run command prompt commands from my java program.  However I am not aware of how I can get the output the command returns.</p>

<p>Here is my code.</p>

<pre><code>Runtime rt = Runtime.getRuntime();

String[] commands = {"system.exe","-send",argument};

Process proc = rt.exec(commands);
</code></pre>

<p>I tried doing system.out.print(proc); but that did not return anything.  The execution of that command should return two numbers separated by a semicolon, how could I get this in a variable to print out?</p>

<p>Thanks,</p>

<p>Here is the code I am using now:</p>

<pre><code>String[] commands = {"system.exe","-get t"};

Process proc = rt.exec(commands);

InputStream stdin = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(stdin);
BufferedReader br = new BufferedReader(isr);

String line = null;
System.out.println("&lt;OUTPUT&gt;");

while ( (line = br.readLine()) != null)
     System.out.println(line);

System.out.println("&lt;/OUTPUT&gt;");
int exitVal = proc.waitFor();
System.out.println("Process exitValue: " + exitVal);
</code></pre>

<p>But I am not getting anything as my output but when I run that command myself it works fine.</p>
