code: public static Iterable<File> iterFilesRecursive(final File dir,
        final Pattern pattern) {
      return new Iterable<File>() {
        public Iterator<File> iterator() {
          return new AbstractIterator<File>() {
            private final Queue<File> files = new LinkedList<File>(Collections
                .singleton(dir));
            private File file = this.findNext();
  
            @Override
            public boolean hasNext() {
              return this.file != null;
            }
  
            @Override
            public File next() {
              File result = this.file;
              if (result == null) {
                throw new NoSuchElementException();
              }
              this.file = this.findNext();
              return result;
            }
  
            private File findNext() {
              File next = null;
              while (!this.files.isEmpty() && next == null) {
                next = this.files.remove();
                if (next.isDirectory()) {
                  files.addAll(Arrays.asList(next.listFiles()));
                  next = null;
                } else if (pattern != null) {
                  if (!pattern.matcher(next.getPath()).find()) {
                    next = null;
                  }
                }
              }
              return next;
            }
          };
        }
      };
    }
docs: Iterate over all the files in the directory, recursively.
  
  @param dir
  The root directory.
  @param pattern
  A regular expression that the file path must match. This uses
  Matcher.find(), so use ^ and $ to specify endpoints.
  @return All files within the directory.