我正在尝试在我的 Eclipse 插件项目中使用Properties 的方法。load()
因为我想将属性文件放在这样的文件夹中:
Pluging Project/
|
+----/src/...
+----/config/config.properties
+----/icons/...
+----META-IN/
+----build.properties
+----plugin.xml
然后我尝试这样的代码但失败了:
Properties prop = new Properties();
InputStream inputStream = (InputStream) Activator.getDefault().getBundle().getEntry("/config/config.properties").getContent();
prop.load(inputStream);
此方法接收输入字节流作为参数。而且我很确定会Activator.getDefault().getBundle().getEntry()
返回一个 InputStream。如果我将属性文件放在调用类的同一位置并使用
InputStream inputStream = this.getClass().getResourceAsStream("config.properties");
它会顺利的。
那么有什么提示吗?