Friday, 22 April 2011

check file on java

package check;

import java.io.File;

public class Main {

    public static void main(String[] args)
    {
        File obj = new File("E:\\go\\hideandseek.txt");

        if(obj.exists())
        {
            System.out.println(obj.getName() + " File exists.");
        }
        else
        {
            System.out.println(obj.getName() + " File DOES NOT exist.");
        }
    }
}

No comments:

Post a Comment