import java.io.*;
public class FileOrDirectoryExists{
public static void main(String args[]){
File file=new File("Any file name or directory whether exists or not");
boolean exists = file.exists();
if (!exists) {
// It returns false if File or directory does not exist
System.out.println("the file or directory you are searching does not exist : " + exists);
}else{
// It returns true if File or directory exists
System.out.println("the file or directory you are searching does exist : " + exists);
}
}
}In this code, I am going to explain about the Checking File Or Directory in the System in Java Program
