code: private static void checkDir(File dir) throws FileNotFoundException, IllegalArgumentException {
          if (!dir.exists())
              throw new FileNotFoundException(dir.getAbsolutePath());
          if (!dir.isDirectory())
              throw new IllegalArgumentException("The provided File object is not a directory: " + dir.getAbsolutePath());
      }
docs: This method is used to throw useful exceptions when the eachFile* and eachDir closure methods
  are used incorrectly.
  
  @param dir The directory to check
  @throws FileNotFoundException    if the given directory does not exist
  @throws IllegalArgumentException if the provided File object does not represent a directory
  @since 1.0