title: Get output from BAT file using Java
body: <p>I'm trying to run a .bat file and get the output. I can run it but I can't get the results in Java:</p>
  
  <pre><code>String cmd = "cmd /c start C:\\workspace\\temp.bat";
  
  Runtime r = Runtime.getRuntime();
  Process pr = r.exec(cmd);
  
  BufferedReader stdInput = new BufferedReader(
      new InputStreamReader( pr.getInputStream() ));
  
  String s ;
  while ((s = stdInput.readLine()) != null) {
      System.out.println(s);
  }
  </code></pre>
  
  <p>The result is <code>null</code>. No idea why I get this. Note that I'm using Windows 7.</p>