Poke. Sorry, I am still not understanding this. If anyone could respond, that would be helpful.
On Mon, Aug 17, 2026 at 12:22 PM David Alayachew <[email protected]> wrote: > Sorry, I am still confused. Isn't it slower to use the BiPredicate? You're > already fetching the attributes to potentially not even use them at all. > Whereas with walk, they are not fetched at all, only when the user > explicitly calls for it. > > My reading of the documentation is that find is faster than walk when you > may or may not want to fetch the attributes. Sorry, you might have to spell > this out for me Alan. > > On Mon, Aug 17, 2026 at 10:29 AM Alan Bateman <[email protected]> > wrote: > >> >> >> On 17/08/2026 14:59, David Alayachew wrote: >> >> : >> >> Did they mean to say compared? And if so, I am a little confused -- isn't >> it >> Files.walk<https://docs.oracle.com/en/java/javase/26/docs/api/java.base/java/nio/file/Files.html#walk(java.nio.file.Path,int,java.nio.file.FileVisitOption...)> >> >> <https://docs.oracle.com/en/java/javase/26/docs/api/java.base/java/nio/file/Files.html#walk(java.nio.file.Path,int,java.nio.file.FileVisitOption...)> >> that >> does not fetch BasicFileAttributes? >> >> Or did they mean something else? Based on the fact that this method fetches >> attributes while walk seemingly does not, one would think that walk is the >> faster method than find, at least on paper. >> >> Could someone help clarify this? >> >> >> It should say "Compared" rather than "Compare" but it is otherwise >> correct. >> >> It just means it may be more efficient to have the source stream be >> filtered rather than have a filter read the attributes for each >> file/element, e.g >> >> Files.walk(dir).filter(Files::isRegularFile).* >> >> vs. >> >> Files.find(dir, Integer.MAX_VALUE, (_, attrs) -> attrs.isRegularFile()).* >> >> -Alan >> >> >>
