public final class FileIterator extends Object
FileIterator
enables iteration over all files in a directory and all
its sub directories.
FileIterator iter = new FileIterator(new File("./src")); File f; while ((f = iter.next()) != null) { // do something with f assert f == iter.getCurrent(); }
Constructor and Description |
---|
FileIterator(File... filesOrDirectories)
Create a new
FileIterator using the specified 'filesOrDirectories' as root. |
Modifier and Type | Method and Description |
---|---|
File |
getFile()
Return the last returned file or
null if no more files are available. |
boolean |
isRootFile()
Return
true if the current file is one of the files originally
specified as one of the constructor file parameters, i.e. is a root file
or directory. |
File |
next()
Return the next
File object or null if no more files are
available. |
public FileIterator(File... filesOrDirectories)
FileIterator
using the specified 'filesOrDirectories' as root.
filesOrDirectories
- Zero or more File
objects, which are iterated
in the specified order (depth first)public File getFile()
null
if no more files are available.next()
public boolean isRootFile()
true
if the current file is one of the files originally
specified as one of the constructor file parameters, i.e. is a root file
or directory.public File next() throws IOException
File
object or null
if no more files are
available.IOException
getFile()
Copyright © 2012-2015. All Rights Reserved.