Java Exception Format formatStackTrace(Exception error)

Here you can find the source of formatStackTrace(Exception error)

Description

format Stack Trace

License

Open Source License

Parameter

Parameter Description
error exception which will be formated into string

Return

stack trace as string

Declaration

public static String formatStackTrace(Exception error) 

Method Source Code

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

public class Main {
    /**/*  w w w .  j a v a 2 s  .  c  om*/
     * 
     * @param error exception which will be formated into string
     * @return stack trace as string
     */
    public static String formatStackTrace(Exception error) {
        final StringBuffer br = new StringBuffer();
        StackTraceElement[] elem = error.getStackTrace();
        for (int i = 0; i < elem.length; i++)
            br.append(elem[i].toString() + "\n");
        return br.toString();
    }
}

Related

  1. formatException(Throwable th)
  2. formatExceptionMsg(String msg)
  3. formatJavaException(Exception e)
  4. formatLogMessage(long id, Throwable exception)
  5. formatMessage(Exception e)