问题
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