简体   繁体   中英

Eclipse: How to retrieve a resource from a bundle

I am using this code to retrieve a folder from a bundle

URL url = Platform.getBundle("myBundle").getEntry("myFolder");
File fileTmp = null;
try {
     fileTmp = new File(FileLocator.resolve(url).toURI());
} catch (URISyntaxException e1) {
  // TODO Auto-generated catch block
  e1.printStackTrace();
 } catch (IOException e1) {
  // TODO Auto-generated catch block
  e1.printStackTrace();
}

The problem is that although it works if I run it as an Eclipse Application, it does not if i export it in the dropins folder and restart Eclipse. In this case it seems the FileLocator fails to resolve the url. Am i missing something?

UPDATE I have opened the jar of the exported plugin and I can't actually find the folder I am trying to retrieve. There has to be something that I should configure before to export the plugin in order to export the folder as well. How can I do that?

See this: Eclipse: how to export a folder in a plugin

而是使用Platform ,尝试通过AbstractUIPlugin实现(如果有)获取资源,例如: Application.getDefault().getBundle().getResource(name)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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