Package com.helger.commons.io.file
Class FileSystemRecursiveIterator
java.lang.Object
com.helger.commons.io.file.FileSystemRecursiveIterator
- All Implemented Interfaces:
ICommonsIterable<File>,IIterableIterator<File>,Iterable<File>,Iterator<File>
@NotThreadSafe
public class FileSystemRecursiveIterator
extends Object
implements IIterableIterator<File>
Recursively iterate the content of a file system directory. This is a depth
first iteration, because as soon as a directory is encountered, the children
of this directory are iterated.
Note: the order of iteration is undefined and depends on the order returned by
Note: the order of iteration is undefined and depends on the order returned by
FileHelper.getDirectoryContent(File).- Author:
- Philip Helger
-
Constructor Summary
ConstructorsConstructorDescriptionFileSystemRecursiveIterator(File aBaseDir) Constructor for recursively iterating a file system directory.FileSystemRecursiveIterator(File aBaseDir, Predicate<File> aRecursionFilter) Constructor for recursively iterating a file system directory.FileSystemRecursiveIterator(String sBaseDir) Constructor for recursively iterating a file system directory.FileSystemRecursiveIterator(String sBaseDir, Predicate<File> aRecursionFilter) Constructor for recursively iterating a file system directory. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.commons.collection.impl.ICommonsIterable
containsAny, containsNone, containsOnly, findAll, findAllInstanceOf, findAllMapped, findAllMapped, findAllMapped, findFirst, findFirst, findFirstIndex, findFirstMapped, findFirstMapped, findLastIndex, forEachBreakable, forEachByIndex, forEachThrowing, getCount, getCountMethods inherited from interface com.helger.commons.collection.iterate.IIterableIterator
iterator, withFilter, withMapperMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
FileSystemRecursiveIterator
Constructor for recursively iterating a file system directory.- Parameters:
sBaseDir- The base directory to start with. May not benull.
-
FileSystemRecursiveIterator
Constructor for recursively iterating a file system directory.- Parameters:
aBaseDir- The base directory to start with. May not benull.
-
FileSystemRecursiveIterator
public FileSystemRecursiveIterator(@Nonnull String sBaseDir, @Nullable Predicate<File> aRecursionFilter) Constructor for recursively iterating a file system directory.- Parameters:
sBaseDir- The base directory to start with. May not benull.aRecursionFilter- An optional filter that controls, into which sub-directories this iterator should descend to. May benull.
-
FileSystemRecursiveIterator
public FileSystemRecursiveIterator(@Nonnull File aBaseDir, @Nullable Predicate<File> aRecursionFilter) Constructor for recursively iterating a file system directory.- Parameters:
aBaseDir- The base directory to start with. May not benull.aRecursionFilter- An optional filter that controls, into which sub-directories this iterator should descend to. May benull.
-
-
Method Details
-
getStartLevel
-
getRecursionFilter
-
hasNext
public final boolean hasNext() -
recurseIntoDirectory
Override this method to manually filter the directories, which are recursed into.- Parameters:
aDirectory- The non-nulldirectory- Returns:
trueif all children of this directory should be investigated
-
next
-
getLevel
- Returns:
- The nesting level of the last file retrieved by
next(). Always ≥ 0. The starting directory has level 0.
-
toString
-