1.打开工程下的文件只需要获取IFile就可以
2.打开工程外的文件方式
File file2 = new File(file1.getAbsolutePath()+File.separator+"dsl"+File.separator+"target"+File.separator+"rn"+File.separator+"workspace"+File.separator+"src"+File.separator+"mock"+File.separator+"mock.json");
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());
}
本文详细介绍了在Eclipse IDE环境下如何打开工程内的文件,仅需通过IFile接口即可实现。同时,对于工程外的文件,提供了具体的步骤和代码示例,包括构造文件路径、使用EFS获取文件存储、调用IDE.openEditorOnFileStore方法来打开指定文件。

1720

被折叠的 条评论
为什么被折叠?



