Here you can find the source of getStackTrace(Throwable t)
public static String getStackTrace(Throwable t)
//package com.java2s; import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static String getStackTrace(Throwable t) { if (t == null) { try { throw new Exception(); } catch (Exception e) { t = e;/* w w w . j a v a 2 s .c om*/ } } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); sw.flush(); return sw.toString(); } public static String toString(Object[] arr) { return toString(arr, true); } public static String toString(Object[] arr, boolean square) { if (arr == null) { return "null"; } StringBuffer sb = new StringBuffer(); if (square) { sb.append("["); } else { sb.append("("); } for (int i = 0; i < arr.length; ++i) {// Object o : arr ) { if (i > 0) { sb.append(","); } if (arr[i] == null) { sb.append("null"); } else { sb.append(arr[i].toString()); } } if (square) { sb.append("]"); } else { sb.append(")"); } return sb.toString(); } }