get Exception Detail - Java java.lang

Java examples for java.lang:Throwable

Description

get Exception Detail

Demo Code


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

public class Main {
    public static String getExceptionDetail(Throwable e) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw, true);
        e.printStackTrace(pw);//from ww  w .  jav a 2s.  c o  m
        pw.flush();
        sw.flush();
        return sw.toString();
    }
}

Related Tutorials