title: Reading error stream from a process
body: <p>I am writing a java program to read the error stream from a process . Below is the structure of my code --</p>
  
  <pre><code>ProcessBuilder probuilder = new ProcessBuilder( command );              
  Process process = probuilder.start(); 
  InputStream error = process.getErrorStream();
  InputStreamReader isrerror = new InputStreamReader(error);
  BufferedReader bre = new BufferedReader(isrerror);
  while ((linee = bre.readLine()) != null) {
          System.out.println(linee);
      }
  </code></pre>
  
  <p>The above code works fine if anything is actually written to the error stream of the invoked process. However, if anything is not written to the error stream, then the call to readLine actually hangs indefinitely. However, I want to make my code generic so that it works for all scenarios. How can I modify my code to achieve the same.</p>
  
  <p>Regards,
       Dev</p>