我想获取元数据(创建时间、上次修改时间、大小等)在eclipse中以编程方式打开的所有文件中。
我有在eclipse编辑器中打开的文件列表的代码,我想知道是否可以获得每个文件的元数据。
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference [] editors = page.getEditorReferences();发布于 2019-05-21 02:26:10
你可以试试下面的代码,我给你提供了下面的伪代码。
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference [] editors = page.getEditorReferences();
for (IEditorReference editorReference : editors) {
try {
IEditorInput editorInput = editorReference.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
IFile file = fileEditorInput.getFile();
//Once you get the file, convert it into java.io.File and you can get all the metadata from file
//Write your own logic to print and to check
}
} catch (PartInitException e) {
e.printStackTrace();
}
}https://stackoverflow.com/questions/56226186
复制相似问题