Stop Googling. The answer is staring you right in the face—you just have to read it.
Tip #5 of my blog post Ten Tips for Using Java Stack Traces demonstrates two example of using Java code to extract a Throwable‘s (implying Error or Exception) stack ...