Print the stack trace of an exception

There is an alternate form of Throwable.printStackTrace() that takes a print stream as an argument. http://download.oracle.com/javase/6/docs/api/java/lang/Throwable.html#printStackTrace(java.io.PrintStream)

E.g.

catch(Exception e) {
    e.printStackTrace(System.out);
}

This will print the stack trace to std out instead of std error.

Leave a Comment