Java Throwable to String StackTraceToString(Throwable ex)

Here you can find the source of StackTraceToString(Throwable ex)

Description

Stack Trace To String

License

Apache License

Declaration

public static String StackTraceToString(Throwable ex) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.ByteArrayOutputStream;

import java.io.PrintStream;

public class Main {
    public static String StackTraceToString(Throwable ex) {
        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        PrintStream printStream = new PrintStream(byteStream);
        ex.printStackTrace(printStream);
        printStream.flush();//w ww .  j a v a2  s  .  c om
        String stackTrace = byteStream.toString();
        printStream.close();
        return stackTrace;
    }

    public static String toString(String[] arrStrs) {
        StringBuffer strBuf = new StringBuffer();
        for (int i = 0; i < arrStrs.length; i++) {
            strBuf.append(arrStrs[i] + ", ");
        }
        return strBuf.toString();
    }
}

Related

  1. stackTraceToString(Throwable cause)
  2. stackTraceToString(Throwable e)
  3. stackTraceToString(Throwable e)
  4. stackTraceToString(Throwable eIn)
  5. stackTraceToString(Throwable ex)
  6. stacktraceToString(Throwable t)
  7. stackTraceToString(Throwable t)
  8. stackTraceToString(Throwable t)
  9. stackTraceToString(Throwable t)