title: How to store printStackTrace into a string
body: <p>How can I get the <code>e.printStackTrace()</code> and store it into a <code>String</code> variable?
  I want to use the string generated by <code>e.printStackTrace()</code> later in my program.</p>
  
  <p>I'm still new to Java so I'm not too familiar with <code>StringWriter</code> that I think
  will be the solution. Or if you have any other ideas please let me know.  Thanks</p>