title: Java Process getOutputStream to String
body: <p>Java 8 here. How does one read the data in <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Process.html#getOutputStream--" rel="noreferrer"><code>Process#getOutputStream()</code></a> into a String? I am trying to run a process from inside Java and hook/capture its STDOUT.</p>
  
  <pre><code>Runtime runtime = Runtime.getRuntime();
  Process proc = runtime.exec("consul -v");
  String capturedOutput;
  
  OutputStream os = proc.getOutputStream();
  capturedOutput = howDoIConvert(os);  // &lt;---- ???
  </code></pre>
  
  <p>Looking for the exact code here (not something vague like <code>baos.toString(codepage)</code>. Also interested if I need to <code>close()</code> anything politely.</p>