Java Throwable to String stackTraceToString(Throwable cause)

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

Description

stack Trace To String

License

Open Source License

Declaration

public static String stackTraceToString(Throwable cause) 

Method Source Code


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

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

public class Main {
    public static String stackTraceToString(Throwable cause) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        PrintStream pout = new PrintStream(out);
        cause.printStackTrace(pout);//from   www  .  j a  v a2 s  . co m
        pout.flush();

        try {
            return new String(out.toByteArray());
        } finally {
            try {
                out.close();
            } catch (Exception e) {

            }
        }
    }
}

Related

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