I use the following lambda expression to iterate over PDF files.
public static void run(String arg) {
Path rootDir = Paths.get(arg);
PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:**.pdf");
Files.walk(rootDir)
.filter(matcher::matches)
.forEach(Start::modify);
}
private static void modify(Path p) {
System.out.println(p.toString());
}
This part .forEach(Start::modify);
executes the static method modify from the same class where the lambda expression is located. Is there a possibility to add something like else
clause when no PDF file is found?