以下代码可以在运行时获取Java Class的磁盘路径:
<YOUR CLASS>.class.getProtectionDomain().getCodeSource().getLocation()
本文介绍了一种在Java中获取类文件磁盘路径的方法,通过使用<YOURCLASS>.class.getProtectionDomain().getCodeSource().getLocation()可以实现在运行时获取到类文件的位置。
<YOUR CLASS>.class.getProtectionDomain().getCodeSource().getLocation()

被折叠的 条评论
为什么被折叠?