首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何以编程的方式在eclipse中打开文件的元数据?

问如何以编程的方式在eclipse中打开文件的元数据?
EN

Stack Overflow用户
提问于 2019-05-21 02:16:05
回答 1查看 93关注 0票数 0

我想获取元数据(创建时间、上次修改时间、大小等)在eclipse中以编程方式打开的所有文件中。

我有在eclipse编辑器中打开的文件列表的代码,我想知道是否可以获得每个文件的元数据。

代码语言:javascript
复制
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

IEditorReference [] editors = page.getEditorReferences();
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-21 02:26:10

你可以试试下面的代码,我给你提供了下面的伪代码。

代码语言:javascript
复制
    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();
                }

     }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56226186

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档