要获取当前编辑文件的内容,您可以执行以下操作:
IWorkbenchPart workbenchPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart(); IFile file = (IFile) workbenchPart.getSite().getPage().getActiveEditor().getEditorInput().getAdapter(IFile.class);if (file == null) throw new FileNotFoundException();String content = IOUtils.toString(file.getContents(), file.getCharset());



