find Stack Trace from Throwable - Java java.lang

Java examples for java.lang:Exception

Description

find Stack Trace from Throwable

Demo Code


//package com.java2s;
import java.io.PrintWriter;
import java.io.StringWriter;

public class Main {
    /**/*from w  ww . j ava2 s . co  m*/
     * @param t Throwable
     * @return String
     */
    public static String findStackTrace(Throwable t) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        t.printStackTrace(pw);
        return sw.toString();
    }
}

Related Tutorials