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