Depth stream stream in Java 8
I would like to traverse a directory structure in Java 8 using the Stream API in depth. The reason for this is that I want to sort the content in the files according to the timestamp present in each file, for each directory. Basically, I'm looking for something similar to # walk Files , but for directories. How can I achieve this?
source to share
It is difficult to understand your description of the problem, in the first place what you actually want to do when you say you want to "sort the content in the files according to the timestamp present in each file, based on each directory."
And when you say you want "something like File Passes, but for directories," that means you have a use problem Files.walk
with directories, but it's not clear what problem you have.
Ie, you can just list all subdirectories of the current directory like
Files.walk(Paths.get("")).filter(Files::isDirectory).forEach(System.out::println);
So, if that doesn't fit your goal, you should spend more time developing your goal.
source to share