Determine if file or directory exists - Java File Path IO

Java examples for File Path IO:Directory

Description

Determine if file or directory exists

Demo Code


import java.io.*;
 
public class Main {
 
  public static void main(String[] args) {
    File file = new File("C:/Folder/Demo.txt");
     boolean blnExists = file.exists();
   //ww w.  ja  v  a 2  s  . c  o m
     System.out.println("Does file " + file.getPath() + " exist ?: " + blnExists);
  }
}

Result


Related Tutorials