Java knows when a file exists, when it prints "Found file", but when a file does not exist, it does NOT print "File not found"
File file = new File(filePath, "Test_1.exe");
if (file.exists()){
System.out.println("File found");
}else{
System.out.println("File not found");
}
does anyone know The file path is correct as I double-checked this. It is just strange that if the file does not exist, it will not print, but it will if it does.
I also tried if (! File.exists ()) was out of luck!
source
share