File and bundleresource:// URLs

I've been breaking my head over this for quite a while now and cant find a solution for this problem: I have an Eclipse RCP application that uses a custom library packaged as jar. From the plugin, i am calling a method within the jar. Within this method, i am "getting" a resource using `this.class.getResource(relPath)`, whereas `relPath` is a hardcoded relative path to a file i need. This returns me an `URL` which i can use to construct a `File`. Now, this works perfectly if i am not calling this method from the plugin, but from a simple Java-Program. The difference: Eclipse RCP's classloader returns an `URL` of protocol `bundleresource://` which is not supported by `File`, whereas when running a simple Java-program, a `file://`-URL is returned which is completely fine to construct a `File`. I am aware of the `FileLocator`-class of the Eclipse SDK (which resolves bundleresource-URLs to file-URLs), but i cannot use it within the library because i dont want to tie it to the Eclipse RCP platform - it should be possible to use this lib from non-Eclipse-RCP sources as well. Anyone any idea on how i can load this resource from a relative path in a manner that will work both when the method is called from an Eclipse RCP-Plugin or any other client? I need to construct a `File` on the directory of this relative path to search for files within. I am completely stuck on this... **UPDATE**: If there is a possibility other than using [File#list()][1] to get directory contents this would already help me.. any hints greatly appreciated, [1]: http://docs.oracle.com/javase/6/docs/api/java/io/File.html#list%28java.io.FilenameFilter%29
Can you list the relevant code?

以上就是File and bundleresource:// URLs的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏