Java Throwable to String stackTraceToString(Throwable e)

Here you can find the source of stackTraceToString(Throwable e)

Description

stack Trace To String

License

Open Source License

Declaration

public static String stackTraceToString(Throwable e) 

Method Source Code

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

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

public class Main {
    public static String stackTraceToString(Throwable e) {
        String retValue = null;//ww  w  .  j a  v  a 2  s  .c om
        StringWriter sw = null;
        PrintWriter pw = null;
        try {
            sw = new StringWriter();
            pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            retValue = sw.toString();
        } finally {
            try {
                if (pw != null) {
                    pw.close();
                }
                if (sw != null) {
                    sw.close();
                }
            } catch (IOException ignore) {
            }
        }
        return retValue;
    }
}

Related

  1. stackTraceToString(final Throwable t)
  2. stackTraceToString(final Throwable thr)
  3. stackTraceToString(final Throwable throwable, final boolean expectNull)
  4. stackTraceToString(Throwable cause)
  5. stackTraceToString(Throwable cause)
  6. stackTraceToString(Throwable e)
  7. stackTraceToString(Throwable eIn)
  8. stackTraceToString(Throwable ex)
  9. StackTraceToString(Throwable ex)