title: Printing Runtime exec() OutputStream to console
body: <p>I am trying to get the <code>OutputStream</code> of the <code>Process</code> initiated by <code>exec()</code> to the console. How can this be done?</p>
  
  <p>Here is some incomplete code:</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.File;
  import java.io.IOException;
  import java.io.OutputStream;
  import java.io.PrintStream;
  import java.io.Reader;
  
  public class RuntimeTests
  {
      public static void main(String[] args)
      {
          File path = new File("C:\\Dir\\Dir2");
          String command = "cmd /c dir";
          Reader rdr = null;
          PrintStream prtStrm = System.out;
          try
          {
              Runtime terminal = Runtime.getRuntime();
  
              OutputStream rtm = terminal.exec(command, null, path).getOutputStream();
              prtStrm = new PrintStream(rtm);
              prtStrm.println();
          } 
          catch (IOException e)
          {
              e.printStackTrace();
          }
      }
  }
  </code></pre>