Print stack trace to string


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. public static String stack2string(Exception e) {
  2.  
  3. try {
  4. PrintWriter pw = new PrintWriter(sw);
  5. e.printStackTrace(pw);
  6. return "------
  7. " + sw.toString() + "------
  8. ";
  9. } catch (Exception e2) {
  10. return "bad stack2string";
  11. }
  12. }

URL: http://www.rgagnon.com/javadetails/java-0029.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.