Reputation: 1373
I want to search for a file from Eclipse plugin. I used the following code but it did not work.
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
String str = JOptionPane.showInputDialog(null,
"Please enter the search file name");
for (IProject project : root.getProjects()) {
IFile file = project.getFile(str);
if (file.exists()) {
JOptionPane.showMessageDialog(null, file.getName());
} else {
JOptionPane.showMessageDialog(null, "File Not Found! ");
}
}
Upvotes: 1
Views: 1159
Reputation: 16392
Once you have the file name you can write a recursive method that searches containers for files and more containers. Start with the workspace root. Some things to note:
Upvotes: 3