In C# when you use DirectoryInfo.EnumerateFiles() method of IEnumerable interface, you can start enumerating the collection of names before the whole collection is returned.How to get this in java?
In C# when you use DirectoryInfo.EnumerateFiles() method of IEnumerable interface, you can start enumerating
Share
Before Java 7 you can’t, as far as I’m aware.
File.listFiles()is what you’ve got, basically – with an overload to take aFileFilterof course.Java 7 has a new file system API, including
FileVisitor<T>which may be what you’re after. It’s not quite the same as having a sequence of files which you can access lazily, but it may do what you need. You’d probably want to create a subclass ofSimpleFileVisitor<T>.