我想在我的Eclipse插件項目中使用Properties's load()
方法。因爲我想把對propertie文件的文件夾中是這樣的:爲什麼Eclipse插件開發中的屬性加載方法失敗?
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。 如果我把propertie文件中調用類的同一個位置,並使用
InputStream inputStream = this.getClass().getResourceAsStream("config.properties");
,便能很好。
因此,任何提示?
列出的
config
目錄您是否嘗試過使用[的OpenStream()](http://docs.oracle.com /javase/6/docs/api/java/net/URL.html)而不是'URL'的'getContent()'? – Katona