code: public static void processPath(File path, FileFilter filter, FileProcessor processor) {
      if (path.isDirectory()) {
        // if path is a directory, look into it
        File[] directoryListing = path.listFiles(filter);
        if (directoryListing == null) {
          throw new IllegalArgumentException("Directory access problem for: " + path);
        }
        for (File file : directoryListing) {
          processPath(file, filter, processor);
        }
      } else {
        // it's already passed the filter or was uniquely specified
        // if (filter.accept(path))
        processor.processFile(path);
      }
    }
docs: Apply a function to the files under a given directory and
  perhaps its subdirectories.  If the path is a directory then only
  files within the directory (perhaps recursively) that satisfy the
  filter are processed.  If the <code>path</code>is a file, then
  that file is processed regardless of whether it satisfies the
  filter.  (This semantics was adopted, since otherwise there was no
  easy way to go through all the files in a directory without
  descending recursively via the specification of a
  <code>FileFilter</code>.)
  
  @param path      file or directory to load from
  @param filter    a FileFilter of files to load.  The filter may be null,
  and then all files are processed.
  @param processor The <code>FileProcessor</code> to apply to each
  <code>File</code>