title: How to redirect ProcessBuilder's output to a string?
body: <p>I am using the following code to start a process builder.I want to know how can I redirect its output to a <code>String</code>.</p>
  <pre><code>ProcessBuilder pb = new ProcessBuilder(
      System.getProperty(&quot;user.dir&quot;) + &quot;/src/generate_list.sh&quot;, filename);
  Process p = pb.start();
  </code></pre>
  <p>I tried using <code>ByteArrayOutputStream</code> but it didn't seem to work.</p>