// Log.d("5555555555555", "資訊"+Tools.getMyStackTraceInfo(new Exception()));
// Log.d("5555555555555", "資訊"+Tools.getStackTraceInfo(new Exception()));
/**
*得到Exception所在代碼的行資訊
*如果沒有行資訊,傳回null
*/
public static String getMyStackTraceInfo(Exception e){
StackTraceElement[] trace =e.getStackTrace();
if(trace==null||trace.length==0) return null;
return trace[0].getFileName()+trace[0].getClassName()+trace[0].getMethodName()+trace[0].getLineNumber();
}
/**
*得到Exception所在代碼的行資訊
*如果沒有行資訊,傳回null
*/
public static String getStackTraceInfo(Exception e){
StackTraceElement[] trace =e.getStackTrace();
if(trace==null||trace.length==0) return null;
return trace[0].toString();
}