从eclipse插件访问相对路径 [英] Access relative path from eclipse-plugin
本文介绍了从eclipse插件访问相对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
绝对路径是没有问题的:
URI.createFileURI(C:/ Users / hp / workspace(dke)/SMartGen/StarSchema.profile.uml);
但是如何相对访问本地资源?
URI.createFileURI( 罐子:文件:/%ECLIPSE_HOME%/插件/ SMartGen.jar StarSchema.profile.uml);
不能这样工作....
$ b $
lg martin
解决方案
使用 FileLocator 。
示例:
URL iconUrl = FileLocator.find(Platform.getBundle(myBundle),新路径(icons / someIcon.png),null);
这将获得位于图标中的文件someIcon.png的URL捆绑包中的文件夹myBundle。
Does anyone know how to get a file with uri from a self-made Eclipse Plug-in?
Absolute paths would be no problem:
URI.createFileURI("C:/Users/hp/workspace(dke)/SMartGen/StarSchema.profile.uml");
But how do I access local resources relatively?
URI.createFileURI("jar:file:/%ECLIPSE_HOME%/plugins/SMartGen.jar!StarSchema.profile.uml");
doesn't work this way....
Happy for every answer.
lg martin
解决方案
Use the FileLocator.
Example:
URL iconUrl = FileLocator.find(Platform.getBundle("myBundle"), new Path("icons/someIcon.png"), null);
This will get the URL of a file "someIcon.png" that is located in the "icons" folder in the bundle "myBundle".
这篇关于从eclipse插件访问相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文