Java 读取资源文件


java类中读取项目下的资源文件方式:


读取根目录下的文件: Role.class.getClassLoader().getResource("").getFile().replaceAll("%20", " ") + "/roles.xml" -- 将%20替换为空格


读取同级目录下的文件: Role.class.getResource("").replaceAll("%20", " ")+"roles.xml"
发布了90 篇原创文章 · 获赞 21 · 访问量 47万+

猜你喜欢

转载自blog.csdn.net/yx13649017813/article/details/37116915