Here you can find the source of stackTraceToString(StackTraceElement[] stackTrace, StringBuilder buf)
public static void stackTraceToString(StackTraceElement[] stackTrace, StringBuilder buf)
//package com.java2s; //License from project: Apache License public class Main { public static void stackTraceToString(StackTraceElement[] stackTrace, StringBuilder buf) {//w w w .j av a 2 s . c om String sep = System.getProperty("line.separator"); for (int i = 0; i < stackTrace.length; i++) { StackTraceElement element = stackTrace[i]; buf.append(sep + "\tat " + element.toString()); } } }