Java Stacktrace to String getStacktraceAsString(Exception e)

Here you can find the source of getStacktraceAsString(Exception e)

Description

Produce a string version of a stacktrace.

License

Open Source License

Parameter

Parameter Description
e The Exception containing the stacktrace

Return

The stacktrace as a String.

Declaration

public static String getStacktraceAsString(Exception e) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    /**/* w w  w. ja  v a  2s.  c  o m*/
     * Produce a string version of a stacktrace.
     * @param e The Exception containing the stacktrace
     * @return The stacktrace as a String.
     */
    public static String getStacktraceAsString(Exception e) {
        final Writer result = new StringWriter();
        final PrintWriter printWriter = new PrintWriter(result);
        e.printStackTrace(printWriter);
        return result.toString();
    }
}

Related

  1. getStackTrace(Exception e)
  2. getStackTrace(Exception e)
  3. getStackTrace(Exception exception)
  4. getStackTrace(Exception x)
  5. getStacktraceAsString(Exception e)
  6. getStackTraceAsString(Exception e)
  7. getStackTraceAsString(Exception e)
  8. getStackTraceAsString(String pstrMessage, Exception poException)
  9. getStackTraceFromException(Exception _e)