Here you can find the source of stackTrace(Throwable th)
public static String stackTrace(Throwable th)
//package com.java2s; /*/*from w ww. j a v a 2 s.c om*/ * Copyright (c) Jim Coles (jameskcoles@gmail.com) 2018 through present. * * Licensed under the following license agreement: * * http://www.apache.org/licenses/LICENSE-2.0 * * Also see the LICENSE file in the repository root directory. */ public class Main { public static String stackTrace(Throwable th) { if (th == null) return null; java.io.StringWriter sw = new java.io.StringWriter(); java.io.PrintWriter pw = new java.io.PrintWriter(sw); th.printStackTrace(pw); return sw.toString(); } }