Android获取Java类名文件名方法名行号

Android获取Java类名文件名方法名行号,第1张

概述/***Android打印方法路径*/publicstaticvoidprintMethodPath(){/ew一个异常类Exceptionexception=newException();//调用者上级类名Log.i(TAG,"Class0———>:"+exception.getStackTrace()[0].getClassN
    /**     * AndroID打印方法路径     */    public static voID printMethodpath() {        //new 一个异常类        Exception exception = new Exception();        //调用者上级类名        Log.i(TAG, "Class0———>:" + exception.getStackTrace()[0].getClassname());        //调用者上级的上级类名        Log.i(TAG, "Class1———>:" + exception.getStackTrace()[1].getClassname());        //调用者上级的方法名        Log.i(TAG, "Methodname0———>:" + exception.getStackTrace()[0].getmethodname());        //调用者上级的上级方法名        Log.i(TAG, "Methodname1———>:" + exception.getStackTrace()[1].getmethodname());        //当前方法行号        Log.i(TAG, "line0———>:" + exception.getStackTrace()[0].getlineNumber());        //调用方法行号        Log.i(TAG, "line1———>:" + exception.getStackTrace()[1].getlineNumber());    }
总结

以上是内存溢出为你收集整理的Android获取Java类名/文件名/方法名/行号全部内容,希望文章能够帮你解决Android获取Java类名/文件名/方法名/行号所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1069634.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存