I've noticed today that two topics on the
Exam Topics list that I could not find in the OCP Study Guide by Boyarsky and Selikoff.
Java File I/O (NIO.2): Find a file by using the PathMatcher interfaceJava Streams: ... Develop code that uses parallel streams, including decomposition operation ...
I think the second of these might be referring to the
spliterator, but I'm not sure. Could anyone give me a pointer please?
What I've gleaned regarding PathMatcher
PathMatcher introduces the concept of a "glob" expression for file matching. It is an interface so you cannot instantiate it directly but need to do
syntaxAndPattern takes the form
syntax:pattern where syntax is a case-insensitive "glob" or "regex". Some useful details here:
https://docs.oracle.com/javase/tutorial/essential/io/find.html and
https://docs.oracle.com/javase/tutorial/essential/io/fileOps.html#glob
Examples of a glob:
*.html - unlike regex, you don't need . before the * and the . represents a real dot not any character*.{htm,html,pdf} - curly braces hold a list of options
Once you have the matcher, call the
method on it, which returns a boolean.
What's very useful to know is that the PathMatcher pairs very well with the
FileVisitor and that the
DirectoryStream can be instantiated with a "glob" as a second parameter:
Both of these are topics on the exam!