Java Throwable to String serializeStackTrace(Throwable th)

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

Description

Gets a string representation of a stack trace.

License

Open Source License

Parameter

Parameter Description
th a parameter

Declaration

public static String serializeStackTrace(Throwable th) 

Method Source Code

//package com.java2s;
import java.io.ByteArrayOutputStream;

import java.io.PrintWriter;

public class Main {
    /**/*from  ww  w  . j  a  v  a2 s  .  c  o  m*/
     * Gets a string representation of a stack trace.
     *
     * @param th
     * @return
     */
    public static String serializeStackTrace(Throwable th) {
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        PrintWriter pw = new PrintWriter(bout);
        th.printStackTrace(pw);
        pw.close();
        return bout.toString();

    }
}

Related

  1. getStackTraceString(Throwable tr)
  2. getStackTraceWithoutCause(Throwable throwable)
  3. printStackTrace(Throwable t)
  4. serialize(Throwable t)
  5. serializeStackTrace(Throwable _t)
  6. stackToString(Exception e)
  7. stackToString(Throwable e)
  8. stackToString(Throwable e)
  9. stackToString(Throwable e)