Here you can find the source of stackTraceToCharSequence( final Throwable error)
public static CharSequence stackTraceToCharSequence( final Throwable error)
//package com.java2s; //License from project: Open Source License import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static CharSequence stackTraceToCharSequence( final Throwable error) { final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw); error.printStackTrace(pw);/*from ww w . jav a 2s. co m*/ pw.flush(); return sw.getBuffer(); } }