Monday, May 19, 2008

Converting File to a corresponding IFIle

If you File refers to a file in your workspace, then yes you can convert it
to an IFile.
Use:
java.io.File file = ...;
Path path = new Path(file.getAbsolutePath());
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);

If it's not in the workspace, there is no corresponding IFile so you cannot
convert.

1 comment:

Anil said...

Forgot to mention, took this part of code from http://dev.eclipse.org/newslists/news.eclipse.tools/msg16521.html