Use File object to check if a file exist - Java File Path IO

Java examples for File Path IO:File Operation

Description

Use File object to check if a file exist

Demo Code

import java.io.File;

public class Main {
  public static void main(String[] arg) {
    File f = new File("c:/myfile.txt");

    if (!f.exists())
      System.out.println("The input file does not exist!");

  }/* w  w w.  ja  va2  s.  c  o m*/
}

Related Tutorials