I want to get all directories & sub directories starting from current one.
I found one approach to achieve this with flatMap()
. But it has one level deep:
List<File> files =
Stream.of(new File(".").listFiles())
.flatMap(file -> file.listFiles() == null ?
Stream.of(file) : Stream.of(file.listFiles()))
.collect(toList());
System.out.println("Count: " + files.size());
files.forEach(path -> System.out.println("Path: " + path));
If I'll have next project struckture:
it will show just:
Path: ./test/next1
How to achieve this with Java 1.8 full and deep as follows
Path: ./test/next1/next2/next3