The java nio Files API gives several options to list the contents of a directory:
I am looking for a way to be able to recursively enumerate contents of a directory sorted by name.
The Javadoc of the methods do not mention anything about it, but is there any implicit guarantee about the order of the returned Path objects for these methods?
No order is guaranteed. The documentation for both
listand 3-argwalksays:The documentation for
DirectoryStreamsays:So you should just call
sortedon the stream with a comparator of your choice.