File.exists()function check locatable file exists or not in your mentioned path. See below example:


public class Fileexists {
public static void main(String[] args) throws Exception{

// create new files
File fexist = new File(file_path);

// create new file in the system

// if file exists
boolean bool = fexist.exists();
// this give you true if file exists or false not exists
System.out.println(“File exists: ” + bool);


Please login or Register to submit your answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.