티스토리 뷰

공부

[Java] getMethodName & getClassName

승가비 2021. 12. 29. 19:43
728x90
public static String getClassName() {
	return getClassName(2);
}

public static String getClassName(int depth) {
	Exception e = new Exception();
	e.fillInStackTrace();

	return e.getStackTrace()[depth].getClassName();
}

public static String getMethodName() {
	return getMethodName(2);
}

public static String getMethodName(int depth) {
	Exception e = new Exception();
	e.fillInStackTrace();

	return e.getStackTrace()[depth].getMethodName();
}
728x90

'공부' 카테고리의 다른 글

[Java] Integer.toBinaryString(int i)  (0) 2022.01.01
[Sh] rmdir ... || true  (0) 2021.12.29
[Linux] Too many levels of symbolic links  (0) 2021.12.29
[HTTPS] basic  (0) 2021.12.28
[Spring] boot X kafka  (0) 2021.12.28
댓글