Recursively list all files in eclipse workspace programmatically

依然范特西╮ 提交于 2019-12-17 14:28:32

问题


I am getting workspace by calling ResourcesPlugin.getWorkspace().getRoot().

How I can list all files(IFile) recursively in the workspace.


回答1:


The root, projects and folders in a workspace all implement the IContainer interface.

Call IContainer.members() to get all the resources in the container.

Something like:

void processContainer(IContainer container) throws CoreException
{
   IResource [] members = container.members();
   for (IResource member : members)
    {
       if (member instanceof IContainer)
         processContainer((IContainer)member);
       else if (member instanceof IFile)
         processFile((IFile)member);
    }
} 


来源:https://stackoverflow.com/questions/20744012/recursively-list-all-files-in-eclipse-workspace-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!