Get a String version of a stacktrace
1 2 Throwable t = new Throwable(); // test code 3 4 final Writer result = new StringWriter(); 5 final PrintWriter printWriter = new PrintWriter(result); 6 t.printStackTrace(printWriter); 7 result.toString();
DZone Snippets > frost137 > stack
12736 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
1 2 Throwable t = new Throwable(); // test code 3 4 final Writer result = new StringWriter(); 5 final PrintWriter printWriter = new PrintWriter(result); 6 t.printStackTrace(printWriter); 7 result.toString();