Posted By

ziuek on 05/16/11


Tagged

java String exception stack trace


Versions (?)

Print stack trace to string


 / Published in: Java
 

URL: http://www.rgagnon.com/javadetails/java-0029.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. }

Report this snippet  

You need to login to post a comment.