首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

获取步骤调用信息

2012-08-30 
获取方法调用信息public class TestMethod {public void t2Method() {getCaller()}public void getCaller

获取方法调用信息

public class TestMethod {public void t2Method() {getCaller();}public void getCaller() {StackTraceElement stack[] = Thread.currentThread().getStackTrace();for (StackTraceElement ste : stack) {if ((ste.getClassName().indexOf("TestMethod")) != -1) {System.out.println("called by " + ste.getClassName() + "."+ ste.getMethodName() + "/" + ste.getFileName());}}}public static void main(String[] args) {new TestMethod().t2Method();}}

热点排行