代码改变世界

eclipse、eclipse_rcp工程发布前、eclipse_rcp工程发布后

2017-04-27 21:45  wenky_wu  阅读(519)  评论(0编辑  收藏  举报

接着上节说到的相对路径问题

eclipse的相对路径是相对于项目工程的路径:在这里可以直接使用Document doc = reader.read(new File("student.xml"));

 

eclipse_rcp产品发布前的相对路径是相对于源码路径

InputStream in = MAC.class.getClassLoader().getResourceAsStream("student.xml");

Document doc = reader.read(new File(in));

eclipse_rcp产品发布后的相对路径是相对于产品打包后的安装路径

FileLocator.toFileURL(Platform.getBundle(Activator.PLUGIN_ID).getEntry("student.xml")).getPath()