如何在Java中将文件转换为IFile,对于项目外的文件? [英] How to convert from File to IFile in java, for files outside the project?

查看:126
本文介绍了如何在Java中将文件转换为IFile,对于项目外的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,此代码用于从文件转换为 IFile

Normally, this code is used for converting from File to IFile:

IWorkspace workspace= ResourcesPlugin.getWorkspace();    
IPath location= Path.fromOSString(file.getAbsolutePath()); 
IFile ifile= workspace.getRoot().getFileForLocation(location);

但这只适用于项目中的java文件。 文件文件不在工作区(而不是项目中)时,如何获取 IFile

But this only works for java files within the project. How can I get the IFile when File file is not in the workspace (not in the project)?

推荐答案

我需要使用Eclipse AST框架中的绑定解决方案。但显然,这是不可能的 - 对于任何需要它的人,请查看这个网站:

I needed this for using the Binding Resolutions from the Eclipse AST framework. But apparently, this is not possible - for anyone who need it, check this site:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=206391

这篇关于如何在Java中将文件转换为IFile,对于项目外的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆