Here you can find the source of stackTrace(Throwable t)
public static final String stackTrace(Throwable t)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; import java.io.PrintWriter; public class Main { public static final String stackTrace(Throwable t) { String s = null;//w w w. j av a2 s . com try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); t.printStackTrace(new PrintWriter(baos, true)); s = baos.toString(); } catch (Exception e) { } return s; } }