org.atmosphere.util
Class FileIterator

java.lang.Object
  extended by org.atmosphere.util.FileIterator

public final class FileIterator
extends Object

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
FileIterator(File... filesOrDirectories)
          Create a new FileIterator using the specified 'filesOrDirectories' as root.
 
Method Summary
 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.
 File next()
          Return the next File object or null if no more files are available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileIterator

public FileIterator(File... filesOrDirectories)
Create a new FileIterator using 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 more File objects, which are iterated in the specified order (depth first)
Method Detail

getFile

public File getFile()
Return the last returned file or null if no more files are available.

See Also:
next()

isRootFile

public 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.


next

public File next()
          throws IOException
Return the next File object or null if no more files are available.

Throws:
IOException
See Also:
getFile()


Copyright © 2013. All Rights Reserved.