Here you can find the source of StackTraceToString(Throwable ex)
public static String StackTraceToString(Throwable ex)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; import java.io.PrintStream; public class Main { public static String StackTraceToString(Throwable ex) { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(byteStream); ex.printStackTrace(printStream); printStream.flush();//w ww . j a v a2 s . c om String stackTrace = byteStream.toString(); printStream.close(); return stackTrace; } public static String toString(String[] arrStrs) { StringBuffer strBuf = new StringBuffer(); for (int i = 0; i < arrStrs.length; i++) { strBuf.append(arrStrs[i] + ", "); } return strBuf.toString(); } }