What is the order in which Files.walkFileTree visits files/directories at the same level?
It doesn’t appear to visit them in order of size, last modified time or name. I couldn’t find anything in the API documentation either.
Perhaps the preVisitDirectory method can be used to specify the order of visit but what is default behaviour ?
The order in which the subdirectories are read is not defined as per this comment in the Java Tutorial:
As for the order in which the files are read, it depends (in the current implementation) on the supplied
DirectoryStream, which issun.nio.fs.WindowsDirectoryStreamon my computer. Reading the javadoc ofDirectoryStream, you will see that: