src/main/java/de/dfki/lt/loot/util/FileUtil.java
public static Iterable<File> findAllFiles(final List<String> names) {
    return new Iterable<File>() {
      public Iterator<File> iterator() {
        return new Iterator<File>() {
          private int dirIndex = 0;
          private File[] dirList = null;
          private File next = null;
          private Iterator<String> currentName = names.iterator();

          private File getNextFromDir() {
            File the_next;
            do {
              the_next = dirList[dirIndex++];
            } while (dirIndex < dirList.length && ! the_next.isFile());
            if (dirIndex >= dirList.length)
              dirList = null;
            return (the_next.isFile() ? the_next : null);
          }

          @Override
          public boolean hasNext() {
            next = (dirList != null) ? getNextFromDir() : null;
            while (next == null && currentName.hasNext()) {
              String name = currentName.next();
              next = new File(name);
              if (next.isDirectory()) {
                dirList = next.listFiles();
                dirIndex = 0;
                next = getNextFromDir();
              }
            }
            return (next != null);
          }

          @Override
          public File next() {
            File result = next;
            next = null;
            return result;
          }

          @Override
          public void remove() {
            throw new UnsupportedOperationException();
          }
        };
      }
    };
  }
/** Return an iterator that iterates over all files in the given list. If one
   *  of the strings points to a directory, the files in the directory are
   *  returned one after the other.
   *
   *  Currently, that does only recurse one level deep.
   *  TODO: include full recursion (optionally).
   */
Return an iterator that iterates over all files in the given list. If one
of the strings points to a directory, the files in the directory are
returned one after the other.

Currently, that does only recurse one level deep.
TODO: include full recursion (optionally).
Return an iterator that iterates over all files in the given list . If one of the strings points to a directory the files in the directory are returned one after the other . Currently that does only recurse one level deep . TODO : include full recursion ( optionally ) .
public static Iterable<File> findAllFiles(final List<String> names) {
    return new Iterable<File>() {
      public Iterator<File> iterator() {
        return new Iterator<File>() {
          private int dirIndex = 0;
          private File[] dirList = null;
          private File next = null;
          private Iterator<String> currentName = names.iterator();
          private File getNextFromDir() {
            File the_next;
            do {
              the_next = dirList[dirIndex++];
            } while (dirIndex < dirList.length && ! the_next.isFile());
            if (dirIndex >= dirList.length)
              dirList = null;
            return (the_next.isFile() ? the_next : null);
          }
          @Override
          public boolean hasNext() {
            next = (dirList != null) ? getNextFromDir() : null;
            while (next == null && currentName.hasNext()) {
              String name = currentName.next();
              next = new File(name);
              if (next.isDirectory()) {
                dirList = next.listFiles();
                dirIndex = 0;
                next = getNextFromDir();
              }
            }
            return (next != null);
          }
          @Override
          public File next() {
            File result = next;
            next = null;
            return result;
          }
          @Override
          public void remove() {
            throw new UnsupportedOperationException();
          }
        };
      }
    };
  }
public static Iterable < File > findAllFiles ( final List < String > names ) { return new Iterable < File > ( ) { public Iterator < File > iterator ( ) { return new Iterator < File > ( ) { private int dirIndex = 0 ; private File [ ] dirList = null ; private File next = null ; private Iterator < String > currentName = names . iterator ( ) ; private File getNextFromDir ( ) { File the_next ; do { the_next = dirList [ dirIndex ++ ] ; } while ( dirIndex < dirList . length && ! the_next . isFile ( ) ) ; if ( dirIndex >= dirList . length ) dirList = null ; return ( the_next . isFile ( ) ? the_next : null ) ; } @ Override public boolean hasNext ( ) { next = ( dirList != null ) ? getNextFromDir ( ) : null ; while ( next == null && currentName . hasNext ( ) ) { String name = currentName . next ( ) ; next = new File ( name ) ; if ( next . isDirectory ( ) ) { dirList = next . listFiles ( ) ; dirIndex = 0 ; next = getNextFromDir ( ) ; } } return ( next != null ) ; } @ Override public File next ( ) { File result = next ; next = null ; return result ; } @ Override public void remove ( ) { throw new UnsupportedOperationException ( ) ; } } ; } } ; }
Return an iterator that iterates over all files in the given list.
Return an iterator that iterates over all files in the given list .