I need to capture the exception in a text file in Java. For example:
try { File f = new File(\"\"); } catch(FileNotFoundException f) { f.printStackTrac
There is an API in Throwable interface getStackTrace() which is used internally for printing in console by printStackTrace()
Throwable
getStackTrace()
printStackTrace()
http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Throwable.html#getStackTrace()
Try this API to get StackTraceElement and print those elements sequentially.
StackTraceElement