Here you can find the source of printStackTrace(Throwable e)
public static String printStackTrace(Throwable e)
//package com.java2s; import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static String printStackTrace(Throwable e) { StringWriter stm = new StringWriter(); PrintWriter wrt = new PrintWriter(stm); e.printStackTrace(wrt);//from www . j a va2s . c o m wrt.close(); return stm.toString(); } public static String toString(String[] content, String sign) { if (null == content) { return null; } sign = null == sign ? "," : sign; StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < content.length; i++) { strBuilder.append(content[i]); if (i < content.length - 1) { strBuilder.append(sign); } } return strBuilder.toString(); } }