Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 org.eclipse.core.runtime.Path 对象。这将具有一些值,例如 Test/src/jsp —— 其中 Test 是项目名称。从这里我想获得该路径中的文件列表,即 IFile []。你能建议一种方法吗?
您可以通过获取 src/ 文件夹IFolder folder = project.getFolder(new Path("/src/")) ,然后通过获取此文件夹中的所有资源IResource[] resources = folder.members()。
IFolder folder = project.getFolder(new Path("/src/"))
IResource[] resources = folder.members()
因此,您只需要提取所有 IFile,例如
for(IResource resource : resources) { if(resource instanceof IFile) //do something }