简体   繁体   中英

Project name under workspace Eclipse

I need to store the project names under a workspace into a list. I'm searching for a predefined function that returns all the project names in the workspace. Is in Eclipse such a function ? (plugin project)

Thank you !

This will get the names in a list:

IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

IProject [] projects = root.getProjects();

List<String> names = new ArrayList<>();

for (IProject project : projects) {
   names.add(project.getName());
}

This code must be run in a Eclipse plugin or headless app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM