Java Throwable to String getStackTrace(Throwable tException)

Here you can find the source of getStackTrace(Throwable tException)

Description

This method returns the string-representation of the stacktrace of the passed on exception.

License

Apache License

Parameter

Parameter Description
tException The exception to get the stacktrace of.

Return

The string-representation of the stacktrace.

Declaration

public static String getStackTrace(Throwable tException) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

public class Main {
    /**/*w w w .ja v  a 2  s.  c  o m*/
     * This method returns the string-representation of the stacktrace of the passed on exception.
     *
     * @param   tException  The exception to get the stacktrace of.
     *
     * @return  The string-representation of the stacktrace.
     */
    public static String getStackTrace(Throwable tException) {
        // Get the stack-trace
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        tException.printStackTrace(pw);
        pw.flush();

        return sw.getBuffer().toString();
    }
}

Related

  1. getStackTrace(Throwable t)
  2. getStackTrace(Throwable t)
  3. getStackTrace(Throwable t)
  4. getStackTrace(Throwable t)
  5. getStackTrace(Throwable t0)
  6. getStackTrace(Throwable th)
  7. getStackTrace(Throwable throwable)
  8. getStackTrace(Throwable throwable)
  9. getStackTrace(Throwable throwable)