Java Programmer since 1999.
The views expressed in this blog are my own and do not in any way represent the views of my Employer or any other organizations I am affiliated to.
The snippet below prints the first class in the stacktrace. Might be useful for logging in some situations.
public vid test () { Throwable th = new Throwable(); stackTraceElement[] ste = th.getStackTrace(); System.out.println(ste[ste.length -1].getClassName()); }
No comments:
Post a Comment