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