我在加载时遇到问题
test.xml and test.properties
在同一文件夹conf中。
我在 dist 文件夹中有一个 myProject.jar ,
conf 文件夹内的 test.xml 和 test.properties。
要加载 xml,我正在使用
document = reader.read(new File("../conf/test.xml"));//its working
但我在加载属性文件时遇到问题,
我在用
Class_name.class.getResourceAsStream("../conf/test.properties"),
getResourceAsStream("conf/test.properties"),
getResourceAsStream("/test.properties"),
getResourceAsStream("test.properties"),
属性文件没有任何作用。
任何帮助表示赞赏。
为什么不使用该文件并加载它FileInputStream
Properties properties = new Properties();
properties.load(new FileInputStream(fileName));
上面的代码将获取属性文件并将其加载到属性对象中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)