首页 > 其他 > 详细

获取当前运行的类名或者方法

时间:2014-11-14 15:24:38      阅读:283      评论:0      收藏:0      [点我收藏+]

public static String getCurrentMethodName() {
int level = 1;
StackTraceElement[] stacks = new Throwable().getStackTrace();
String methodName = stacks[level].getMethodName();
return methodName;
}

public static String getCurrentClassName() {
int level = 1;
StackTraceElement[] stacks = new Throwable().getStackTrace();
String className = stacks[level].getClassName();
return className;
}

获取当前运行的类名或者方法

原文:http://www.cnblogs.com/shortboy/p/4097272.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!