Java: 获取当前执行位置的文件//方法名/行号

JAVA 程序有时需要获取当前代码位置, 于是就利用 Thread.currentThread().getStackTrace() 写了下面这个工具, 用来获取当前执行位置处代码的文件//方法名/行号. 当然通过 new Throwable().getStackTrace ...

Wed Apr 05 07:04:00 CST 2017 0 4782
Java获取当前方法名

获取class: this.getClass().getName(); 或者 Thread.currentThread().getStackTrace()[1].getClassName(); 获取方法名: Thread.currentThread().getStackTrace ...

Thu Jan 02 21:53:00 CST 2020 0 6876
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM