åèå
容å¦ä¸:
public class Debug {
public static int line(Exception e) {
StackTraceElement[] trace = e.getStackTrace();
if (trace == null || trace.length == 0)
return -1; //
return trace[0].getLineNumber();
}
public static String fun(Exception e) {
StackTraceElement[] trace = e.getStackTrace();
if (trace == null)
return ""; //
return trace[0].getMethodName();
}
}
ãã使ç¨åºæ¯ï¼
public class test {
public static String DI(Exception e) {
return Debug.line(e)+"|"+Debug.fun(e)+"|";
}
public test() {
Log.d(TAG, DI(new Exception())); //è¿éå°±è¾åºæ们éè¦çdebugä¿¡æ¯äº
}
}
温馨提示:内容为网友见解,仅供参考