Getting the caller method details using Java

public static String getCallerClassName() {
StackTraceElement[] stElements = Thread.currentThread().getStackTrace();
for (int i=1; i<stelements.length; i++)="" {="" stacktraceelement="" ste="stElements[i];" if="" (!ste.getclassname().equals(your_currentclass.class.getname())="" &&="" ste.getclassname().indexof("java.lang.thread")!="0)" return="" ste.getclassname()+"."+="" ste.getmethodname()+"()";="" }="" null;="" <="" code=""></stelements.length;>

Leave a Reply

Your email address will not be published. Required fields are marked *


9 − seven =