Java获取当前类名和方法名

获取class名:

this.getClass().getName();

或者

Thread.currentThread().getStackTrace()[1].getClassName();

获取方法名:

Thread.currentThread().getStackTrace()[1].getMethodName();

获取行号:

Thread.currentThread().getStackTrace()[1].getLineNumber();

获取文件名(带后缀):

Thread.currentThread().getStackTrace()[1].getFileName();

原文地址:https://www.cnblogs.com/mjtabu/p/12132551.html