title: How to redirect printstream to JTextArea?
body: <p>I am writing a pattern generator and here is the chief code (character for pattern and steps are provided by JTextFields):</p>
  
  <pre><code>String chstrin=ch.getText();
  char c=chstrin.charAt(0);
  int n = Integer.parseInt(st.getText()) ;
  
  for(int i = 0; i &lt;= n; ++i)
  {
      for(int k = 0; k &lt; i*2-1; ++k)
          System.out.print(c);
  
      System.out.println();
  }
  </code></pre>
  
  <p>How do I redirect the output to a JTextArea by the name of "res"?
  I did read about System.setOut and PipedOutput on both StackOverflow and the net but can't understand a single line of code.
  Can anyone help me out? Please use JTextArea res as your output.</p>
  
  <p>Thanks!</p>