Here you can find the source of getStackTraceAsString(Exception e)
private static String getStackTraceAsString(Exception e)
//package com.java2s; import java.io.*; public class Main { private static String getStackTraceAsString(Exception e) { ByteArrayOutputStream stackTrace = new ByteArrayOutputStream(); PrintWriter pw = new PrintWriter(stackTrace); e.printStackTrace(pw);//from w w w . j av a 2 s.c o m pw.close(); return stackTrace.toString(); } }