Eclipse plugin 如何在eclipse&;中从捆绑包加载文件;我的日食?

Eclipse plugin 如何在eclipse&;中从捆绑包加载文件;我的日食?,eclipse-plugin,Eclipse Plugin,这是我在开发插件时注意到的非常奇怪的行为。 我在捆绑包中有一个文件,必须为向导加载该文件。 我尝试使用以下代码在eclipse中加载该文件 Bundle bundle = Platform.getBundle(MTPAppPlugin.getDefault() .getBundle().getSymbolicName()); URL fileURL = bundle.getEntry(relativeFilePath); File

这是我在开发插件时注意到的非常奇怪的行为。 我在捆绑包中有一个文件,必须为向导加载该文件。 我尝试使用以下代码在eclipse中加载该文件

Bundle bundle = Platform.getBundle(MTPAppPlugin.getDefault()
                .getBundle().getSymbolicName());
        URL fileURL = bundle.getEntry(relativeFilePath);
        File file = new File(FileLocator.resolve(fileURL).toURI());
但这在MyEclipse中不起作用,所以我在我的eclipse中使用了另一种方式

url = new URL("platform:/plugin/"
                + MTPAppPlugin.getDefault().getBundle().getSymbolicName()
                + relativeFilePath);
        InputStream inputStream = url.openConnection().getInputStream();
        in = new BufferedReader(new InputStreamReader(inputStream));

现在我需要知道有没有加载eclipse文件的常用方法&myeclipse?

第一种方法似乎是正确的。MyEclipse中给出的错误是什么

如果您的文件夹路径中有C:\program files等空间,则第一个将不起作用。

我的Eclipse无法从包中加载文件。谢谢。。。第二种方法适用于eclipse和MyEclipse。如果不切换到文件,第一种方法也适用。一旦有了URL,只需将其转换为类似于选项2的InputStream。