This example code checks whether the given file is exist or not.

Java Code:
import java.io.*;

public class FileTest {
  public static void main(String args[]) {
    File f = new File("c:\\MyFile.txt");
    System.out.println
      (f + (f.exists()? " is found " : " is missing "));
  }
}