Good Morning, i have used these method to check if a certain file exists in a group of directories:
public static boolean doesFileExist(String[] directories, String fileName) {
String path = " ";
for (String dir : directories) {
path = path + File.separator + dir;
}
System.out.println(path);
File file = new File(path, fileName);
return file.exists();
}
i give the method an array of directories and a file name which is actually exists in one of them, here's the array of directories:
static String[] direstories = { "B:\\eslam\\xml", "B:\\eslam\\xml\\paper" };
and the file ch23.pdf
does exists in the first directory, i think that the method takes a whole string of a group of directories and split it according to a regex like /^[A-z]+$/:
but it violates my expectation as the method returns false with these group of directories \B:\eslam\xml\B:\eslam\xml\paper