stack Trace To String - Java java.lang

Java examples for java.lang:Exception StackTrace

Description

stack Trace To String

Demo Code


//package com.java2s;

public class Main {
    public static final String stackTraceToString(Throwable e) {
        StringBuilder sb = new StringBuilder();
        for (StackTraceElement element : e.getStackTrace()) {
            sb.append(element.toString());
            sb.append("\n");
        }//  w w  w  . j  a  v  a2 s.c o  m
        return sb.toString();
    }
}

Related Tutorials