Here you can find the source of getExceptionString(Throwable e)
public static String getExceptionString(Throwable e)
//package com.java2s; //License from project: Apache License import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static String getExceptionString(Throwable e) { if (e == null) return ""; StringWriter strWriter = new StringWriter(); PrintWriter writer = new PrintWriter(strWriter, true); e.printStackTrace(writer);//from w w w. ja va2 s.co m StringBuffer sb = strWriter.getBuffer(); String s = "cause by: \n\t" + sb.toString(); return s.replace("Caused by:", "<font color='red'>Caused by:"); } public static String toString(Object obj) { if (null == obj) return null; return String.valueOf(obj); } }