Tuesday, 4 August 2015

Checking a file/directory present or not Using Java

    public boolean isFileOrDirectoryPresent(String fileOrDirName){

      File file = new File(fileOrDirName);
      if (!file.exists()){
        System.out.println("File/Directory doesn't exist");
        return false;
      }
      else {
        System.out.println("File/Directory exists");
        return true;
      }
    }

No comments:

Post a Comment