Here you can find the source of stackTraceFromException(Throwable ex)
public static String stackTraceFromException(Throwable ex)
//package com.java2s; //License from project: Apache License import java.io.PrintWriter; import java.io.StringWriter; public class Main { private static String EMPTY = ""; public static String stackTraceFromException(Throwable ex) { if (null == ex) { return EMPTY; }/*from w ww . ja va 2 s . co m*/ StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); ex.printStackTrace(pw); return sw.toString(); } }