开发者

eclipse: Find Resource with a locationURI

How can i find a Resource with a locationURI?

Path path = new Path('/home/foo/eclipse/runtime-EclipseApplication/someproj/B.txt');
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path);

I know there is a way by using the locationURI from current pro开发者_开发百科ject to trim the "needless" part, but is there a "better" way to slove this issue.


You can use the following construction:

ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(URIUtil.toURI(fileName));

where fileName - absolute path of File.getAbsolutePath()

and URIUtil from org.eclipse.core.filesystem


You can use a FileLocator to find the file within your bundle, if that is what you want (instead of finding a file in the runtime workspace), see Retrieve a file from within a folder in the workspace

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜