code: public static Iterator<File> get(String directoryIteratorType, File dir,
              String extensionFilter, boolean recursive) throws IOException {
  
          try {
              // add package name to e.g. "DefaultDirectoryIterator"
              if (directoryIteratorType.indexOf('.') == -1) {
                  directoryIteratorType = DirectoryIterator.class.getPackage()
                          .getName() + "." + directoryIteratorType;
              }
  
              DirectoryIterator it = (DirectoryIterator) Class.forName(
                      directoryIteratorType).newInstance();
              it.setDirectory(dir);
              it.setRecursive(recursive);
  
              if (extensionFilter != null)
                  it.setExtensionFilter(extensionFilter);
              return it.iterator();
          } catch (Throwable t) {
              throw new IOException(t);
          }
      }
docs: Loads a {@link DirectoryIterator} by reflexion and sets dir and
  extensionFilter
  
  @throws IOException
  if anything goes wrong, including {@link RuntimeException}s