StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace()
From the Javadocs:
The last element of the array represents the bottom of the stack, which is the least latest method invocation in the sequence.
A StackTraceElement has getClassName(), getFileName(), getLineNumber() and getMethodName().
You will have to test to decide which index you require (apparently stackTraceElements[1] or [2]).