简体   繁体   English

eclipse插件加载文件

[英]eclipse plugin load file

i have created a plugin which can load the image from the icons folder as follow: 我创建了一个插件,可以从图标文件夹中加载图像,如下所示:

Image image = ImageDescriptor.createFromURL(
            FileLocator.find(bundle, new Path("icons/image.gif"), null))
            .createImage();

It worked fine. 工作正常。

Similarly I have created a folder called "assets" inside eclipse plugin project, & created a file called "Temp.txt" inside it. 同样,我在eclipse插件项目中创建了一个名为“ assets”的文件夹,并在其中创建了一个名为“ Temp.txt”的文件。

But I am unable to find a way to load it into my java class. 但是我找不到将其加载到我的java类中的方法。 Kindly help me out in getting through this. 请帮助我解决这个问题。

Use: 采用:

URL url = FileLocator.find(bundle, new Path("assets/Temp.txt"), null);

URL fileUrl = FileLocator.toFileURL(url);

File file = new File(fileUrl.getPath());

... read the file in the usual way

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM