I\'m curious as to what the difference is between printStackTrace() and toString(). At first sight, they seem to do the exact same thing.
Code:
No, there's a huge difference. If you just call toString, it won't print anything - it will just return a string. A catch block of just e.toString(); is useless. (There's also the matter of the stack trace, as Martijn pointed out.)
Personally I wouldn't use either though - I'd use a logging library (log4j, java.util.logging etc) which takes the Throwable itself as a parameter, and will format it usefully - including the stack trace, potentially truncated to avoid repetition.