package exception;
import java.io.PrintWriter;
import java.io.StringWriter;
public class ExceptionPrinter {
/**
* @param args
*/
public static void main(String[] args) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
// TODO Auto-generated method stub
try {
th();
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(pw);
}
System.out.println(sw.getBuffer().toString());
}
public static void th() throws Exception {
throw new Exception("This is a test!");
}
}