Here you can find the source of stackToString(Exception e)
public static String stackToString(Exception e)
//package com.java2s; //License from project: Open Source License import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static String stackToString(Exception e) { try {//w w w. j a v a 2s . c o m StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); return "------\n" + sw.toString() + "------\n"; } catch (Exception e2) { return "bad stackToString"; } } }