Here you can find the source of getStackTrace(Exception e)
static public String getStackTrace(Exception e)
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.io.UnsupportedEncodingException; public class Main { static public String getStackTrace(Exception e) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); e.printStackTrace(ps);// w ww . j a v a 2 s . co m ps.flush(); try { return baos.toString("UTF-8"); } catch (UnsupportedEncodingException ee) { return baos.toString(); } } }