Java Throwable to String getStackTraceFromBaseException(Throwable exc)

Here you can find the source of getStackTraceFromBaseException(Throwable exc)

Description

get Stack Trace From Base Exception

License

Open Source License

Declaration

public static String getStackTraceFromBaseException(Throwable exc) 

Method Source Code


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

public class Main {

    public static String getStackTraceFromBaseException(Throwable exc) {
        String str = "";
        try {/*from  www.j a v  a  2s .c o m*/
            Exception be = (Exception) exc;
            //java.io.ByteArrayOutputStream
            java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
            PrintStream ps = new PrintStream(baos, false, "UTF8");
            be.printStackTrace(ps);
            str = baos.toString("UTF8");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return str;
    }
}

Related

  1. getStackTraceAsString(Throwable t)
  2. getStackTraceAsString(Throwable t)
  3. getStackTraceAsString(Throwable throwable)
  4. getStackTraceAsString(Throwable throwable)
  5. getStackTraceAsText(Throwable t)
  6. getStackTraceFromThrowable(Throwable t)
  7. getStackTraceInString(Throwable throwable)
  8. getStackTraceLines(Throwable t, int numLines)
  9. getStackTraceOnly(Throwable throwable)