這是我在開發插件時注意到的非常奇怪的行爲。 我必須爲嚮導加載的包中有一個文件。 我試圖使用下面的代碼在eclipse中加載文件。如何在eclipse和My Eclipse中的Bundle中加載文件?
Bundle bundle = Platform.getBundle(MTPAppPlugin.getDefault()
.getBundle().getSymbolicName());
URL fileURL = bundle.getEntry(relativeFilePath);
File file = new File(FileLocator.resolve(fileURL).toURI());
但這didnt在MyEclipse.So工作,我用其他的方式爲我的日食
url = new URL("platform:/plugin/"
+ MTPAppPlugin.getDefault().getBundle().getSymbolicName()
+ relativeFilePath);
InputStream inputStream = url.openConnection().getInputStream();
in = new BufferedReader(new InputStreamReader(inputStream));
現在我需要知道的是有沒有加載日食&我的Eclipse中的文件的任何常用的方法?
如果不切換到一個文件中,第一種方式也能發揮作用。獲得URL後,將其轉換爲類似於選項2的InputStream。 – 2011-04-28 13:16:28