Thursday, November 26, 2009


Example to Determine if a File or Directory Exists

This program checks whether the file or directory exist in your computer or not. This can be possible using exists() method and in the example we are using if condition to check whether the given file or directory exists or not. The example is given below :

import java.io.*;
public class filedirexists{
public static void main(String args[])
{
File filedir=new File("File or Directory exists or not!!")
boolean exists = filedir.exists()
if (!exists)
{
System.out.println("The File/Directory you are looking for is not found")
}
else
{
System.out.println("The File/Directory you are looking for available")


0 comments: