当前位置:网站首页>根据字节码获取类的绝对路径
根据字节码获取类的绝对路径
2022-04-23 08:10:00 【Silence丶你的名字】
适用于当前模块或引入模块。
不适用于第三方jar包
/**
* 根据字节码获取类绝对路径
*
* @param clazz clazz
* @return classRealPath
*/
private static String getClassRealPath(Class<?> clazz) {
String classPath = clazz.getName().replace(".", "/") + ".class";
String classRealPath = Objects.requireNonNull(clazz.getResource("/" + classPath)).getPath();
classRealPath = classRealPath.replace("target/classes", "src/main/java");
classRealPath = classRealPath.replace(".class", ".java");
classRealPath = StrUtil.replace(classRealPath, "/", "\\");
return classRealPath.substring(1);
}
版权声明
本文为[Silence丶你的名字]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_42553504/article/details/124309003
边栏推荐
- 分布式消息中间件框架选型-数字化架构设计(7)
- DOM 学习之—添加+-按钮
- ATSS(CVPR2020)
- JS converts tree structure data into one-dimensional array data
- 396. Rotate Function
- 让地球少些“碳”息 度能在路上
- Large amount of data submitted by form post
- freertos学习02-队列 stream buffer message buffer
- ansible自动化运维详解(一)ansible的安装部署、参数使用、清单管理、配置文件参数及用户级ansible操作环境构建
- Detailed description of self feeling of auricular point weight loss 0422
猜你喜欢
Transformer-XL: Attentive Language ModelsBeyond a Fixed-Length Context 论文总结
分布式消息中间件框架选型-数字化架构设计(7)
How to generate assembly file
Green apple film and television system source code film and television aggregation film and television navigation film and television on demand website source code
clang 如何产生汇编文件
Shell script advanced
5.6 综合案例-RTU-
Vowel substring in statistical string of leetcode simple problem
QT compilation qtxlsx Library
The annotation is self-defined by implementing the parameter parser handlermethodargumentresolver interface
随机推荐
Vowel substring in statistical string of leetcode simple problem
The annotation is self-defined by implementing the parameter parser handlermethodargumentresolver interface
ELK生产实践
vslam PPT
excle加水印
耳穴减肥自身感受细节描述0422
微信小程序 catchtap=“toDetail“ 事件问题
input元素添加监听事件
5.6 综合案例-RTU-
Misunderstanding of flush () method of OutputStream class
Add random attributes to the Li class array objects and sort them
对li类数组对象随机添加特性,并进行排序
面了一圈,整理了这套面试题。。
ATSS(CVPR2020)
【深度好文】Flink SQL流批⼀体化技术详解(一)
Navicat remote connection MySQL
How to generate assembly file
DOM learning - add + - button
分布式消息中间件框架选型-数字化架构设计(7)
synchronized 锁的基本用法