Case-insensitive File.equals on case-sensitive file system
This method will tell you if a file with the exact name in question exists (the path portion is not case sensitive).
public static boolean caseSensitiveFileExists(String pathInQuestion) {
File f = new File(pathInQuestion);
return f.exists() && f.getCanonicalPath().endsWith(f.getName());
}
Get the list of files from the directory (File.list()
) and compare the names using equalsIgnoreCase()
.