Java Throwable to String getStackTrace(final Throwable t)

Here you can find the source of getStackTrace(final Throwable t)

Description

Get a stack trace as a string.

License

Open Source License

Parameter

Parameter Description
t the throwable (including exceptions) with the stack trace.

Return

the stack trace.

Declaration

public static String getStackTrace(final Throwable t) 

Method Source Code

//package com.java2s;

import java.io.PrintWriter;
import java.io.StringWriter;

public class Main {
    /**//  ww w.j  a v a2 s . c om
     * Get a stack trace as a string.
     * @param t the throwable (including exceptions) with the stack trace.
     * @return the stack trace.
     */
    public static String getStackTrace(final Throwable t) {
        final StringWriter sw = new StringWriter();
        t.printStackTrace(new PrintWriter(sw));
        return sw.toString();
    }
}

Related

  1. getStackTrace(final Throwable error)
  2. getStackTrace(final Throwable exception)
  3. getStackTrace(final Throwable t)
  4. getStackTrace(final Throwable t)
  5. getStackTrace(final Throwable t)
  6. getStackTrace(final Throwable throwable)
  7. getStackTrace(Throwable aThrowable)
  8. getStackTrace(Throwable aThrowable)
  9. getStackTrace(Throwable e)