I need to take a caught exception and get a String that is what would be printed using printStackTrace().
It looks like the simplest thing is to call printStackTrace(X), where X subclasses a PrintStream or PrintWriter, and gathers it to a StringBuilder and can return a String.
Does such a thing exist? If not, any suggestions how to do this?
edit: skaffman posted a solution that used getStackTrace(). (can you or moderators undelete?) This is actually the only solution that works "right". The problem with using PrintWriter on top of StringWriter, although it works easily, is that for deep stack traces it doesn't print all the elements.