September 2019
Intermediate to advanced
816 pages
18h 47m
English
Searching for files or folders in a file tree is a common task that's needed in a lot of situations. Thanks to JDK 8 and the new Files.find() method, we can accomplish this pretty easily.
The Files.find() method returns a Stream<Path> which is lazily populated with the paths that match the provided finding constraints:
public static Stream<Path> find( Path start, int maxDepth, BiPredicate<Path, BasicFileAttributes > matcher, FileVisitOption...options) throws IOException
This method acts as the walk() method, and so it traverses the current file tree, starting from the given path (start), and reaching the maximum given depth (maxDepth). During the iteration of the current file tree, this method ...
Read now
Unlock full access