Below function will convert java.io File to eclipse IFile resource.
public IFile convert(File file) {
IWorkspace workspace= ResourcesPlugin.getWorkspace();
IPath location= Path.fromOSString(file.getAbsolutePath());
IFile ifile= workspace.getRoot().getFileForLocation(location);
return ifile;
}
This works only when resource exists with in the workspace.
Accessing the resources outside the workspace:
http://wiki.eclipse.org/FAQ_How_do_I_open_an_editor_on_a_file_outside_the_workspace%3F