title: How could I read Java Console Output into a String buffer
body: <p>I have a Java program that outputs some text into console. It uses <code>print</code>, <code>println</code>, and some other methods to do this.</p>
  
  <p>At the end of the program , I want to read all the text in console and copy it into a String buffer. How could I do this in Java ? I need to read <code>stdout</code> and <code>stderr</code> separately.</p>