Skip to content

Instantly share code, notes, and snippets.

@programaker
Created March 8, 2010 20:14
Show Gist options
  • Select an option

  • Save programaker/325577 to your computer and use it in GitHub Desktop.

Select an option

Save programaker/325577 to your computer and use it in GitHub Desktop.
How to get the stack trace of an exception as String
public String getStackTrace(Exception e) {
Writer stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
return stringWriter.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment