Description Below I present you two different ways to get the current Class: Using Thread ...
Description Below I present you two different ways to get the current Class: Using Thread ...
获取class名: this.getClass().getName(); 或者 Thread.currentThread().getStackTrace()[1].getClassName(); 获取方法名: Thread.currentThread().getStackTrace ...
1、获取当前类名: this.getClass().getSimpleName() 也可以 2、获取当前方法名: ...
很简单,直接看代码: ...
代码如下: ...
获取当前方法的名称空间、类名和方法名称 获取调用者类名和方法名 ...
在 JAVA 程序有时需要获取当前代码位置, 于是就利用 Thread.currentThread().getStackTrace() 写了下面这个工具类, 用来获取当前执行位置处代码的文件名/类名/方法名/行号. 当然通过 new Throwable().getStackTrace ...