发出加载属性文件 [英] issue loading properties file
本文介绍了发出加载属性文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到加载问题
test.xml and test.properties
在同一文件夹conf中。
inside the same folder conf.
我在dist文件夹中有一个myProject.jar在conf文件夹中
test.xml和test.properties。
I have a myProject.jar inside dist folder and test.xml and test.properties inside conf folder.
要加载xml,我正在使用
To load xml, I am using
document = reader.read(new File("../conf/test.xml"));//its working
但我在加载属性文件时遇到问题,
我正在使用
But I am having issue when loading properties file, I am using
Class_name.class.getResourceAsStream("../conf/test.properties"),
getResourceAsStream("conf/test.properties"),
getResourceAsStream("/test.properties"),
getResourceAsStream("test.properties"),
没有什么适用于属性文件。
Nothing is working for properties file.
感谢任何帮助。
推荐答案
为什么不使用 FileInputStr获取文件并加载它eam
Properties properties = new Properties();
properties.load(new FileInputStream(fileName));
上面的代码将获取属性文件并将其加载到属性对象中。
The above code will take the properties file and load it into a properties object.
这篇关于发出加载属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文