Home » java » Checking whether a file or directory

Checking whether a file or directory

Checking whether the File object exists if exists then check whether it is file of directory to check file existance exists() method of File class is used if it returns true means file or directory exists, at this point we are not confirm existing File object is file or directory.
To check file object isDirectory() method is used this method returns true if file object is directory otherwise it return false.
isFile() method is used to check whether the file object is file or not if it is a file then it returns true else false.

Please follow and like us:
error