To determine whether a file is exist in your file system, use the Java IO File.exists().

package com.mkyong.io;
 
import java.io.*;
 
public class FileChecker {
 
  public static void main(String args[]) {
 
	  File f = new File("c:\\mkyong.txt");
 
	  if(f.exists()){
		  System.out.println("File existed");
	  }else{
		  System.out.println("File not found!");
	  }
 
  }
 
}
Tags :
Founder of Mkyong.com and HostingCompass.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.

Related Posts

Popular Posts