Java Throwable to String stackTrace(Throwable th)

Here you can find the source of stackTrace(Throwable th)

Description

stack Trace

License

Apache License

Declaration

public static String stackTrace(Throwable th) 

Method Source Code

//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();
    }
}

Related

  1. stackTrace(Throwable e)
  2. stackTrace(Throwable exception)
  3. stackTrace(Throwable t)
  4. stackTrace(Throwable t)
  5. stackTrace(Throwable t)
  6. stackTrace(Throwable th, String pattern)
  7. stackTrace(Throwable throwable)
  8. stackTraceAsString(final Throwable aError)
  9. stackTraceAsString(Throwable e)