developer155
Programmer
What is the easiest way in java to search a given directory for a file. I have a directory and folder path where I have to fina a file, with name like MyFile.GIF. How can I do it with Java
thanks
thanks
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
public boolean find(String dir, String file) {
File d = new File(dir);
File[] files = d.listFiles();
for (int j = 0; j < files.length; j++) {
if (files[j].toString().equals(file)) {
return true;
}
}
return false;
}