Review the Files.find()
signature.
Files.java
public static Stream<Path> find(Path start,
int maxDepth,
BiPredicate<Path, BasicFileAttributes> matcher,
FileVisitOption... options)
throws IOException
path
, starting file or folder.maxDepth
defined the maximum number of directory levels to search. If we put 1
, which means the search for top-level or root folder only, ignore all its subfolders; If we want to search for all folder levels, put Integer.MAX_VALUE
.BiPredicate<Path, BasicFileAttributes>
is for condition checking or filtering.FileVisitOption
tells if we want to follow symbolic links, default is no. We can put FileVisitOption.FOLLOW_LINKS
to follow symbolic links.
The Merge Cube made us look at AR in a new way
This example uses Files.find()
to find files that matched filename google.png
, starting from the folder C:\\test
, and included all levels of its subfolders.
FileFindExample1.java