Java tutorial
//package com.java2s; import java.io.PrintWriter; import java.io.StringWriter; import java.io.Writer; public class Main { public static String getExceptionStackTrace(Exception e) { Writer writer = new StringWriter(); PrintWriter printWriter = new PrintWriter(writer); e.printStackTrace(printWriter); return writer.toString(); } }