Package org.atmosphere.util.annotation
Class FileIterator
java.lang.Object
org.atmosphere.util.annotation.FileIterator
FileIterator enables iteration over all files in a directory and all
its sub directories.
Usage:
FileIterator iter = new FileIterator(new File("./src"));
File f;
while ((f = iter.next()) != null) {
// do something with f
assert f == iter.getCurrent();
}
- Since:
- annotation-detector 3.0.0
- Author:
- Ronald K. Muller
-
Constructor Summary
ConstructorsConstructorDescriptionFileIterator(File... filesOrDirectories) Create a newFileIteratorusing the specified 'filesOrDirectories' as root. -
Method Summary
Modifier and TypeMethodDescriptiongetFile()Return the last returned file ornullif no more files are available.booleanReturntrueif the current file is one of the files originally specified as one of the constructor file parameters, i.e.next()Return the nextFileobject ornullif no more files are available.
-
Constructor Details
-
FileIterator
Create a newFileIteratorusing the specified 'filesOrDirectories' as root.
If 'filesOrDirectories' contains a file, the iterator just returns that single file. If 'filesOrDirectories' contains a directory, all files in that directory and its sub directories are returned (depth first).- Parameters:
filesOrDirectories- Zero or moreFileobjects, which are iterated in the specified order (depth first)
-
-
Method Details
-
getFile
Return the last returned file ornullif no more files are available.- See Also:
-
isRootFile
public boolean isRootFile()Returntrueif 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. -
next
Return the nextFileobject ornullif no more files are available.- Throws:
IOException- See Also:
-