1.打开工程下的文件只需要获取IFile就可以
2.打开工程外的文件方式
File file2 = new File(“filename”); IFileStore fileStore = EFS.getLocalFileSystem().getStore(new org.eclipse.core.runtime.Path(file2.getAbsolutePath())); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { IDE.openEditorOnFileStore(page, fileStore); } catch (PartInitException e) { String msg = NLS.bind(IDEWorkbenchMessages.OpenLocalFileAction_message_errorOnOpen, fileStore.getName()); IDEWorkbenchPlugin.log(msg,e.getStatus()); }