Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Topics on Exam 1Z0-813 and OCP Study Guide by Boyarsky and Selikoff  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 interface
  • Java 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!
     
    author & internet detective
    Marshal
    Posts: 37896
    594
    Eclipse IDE Java VI Editor
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    John,
    We missed PathMatcher in the book. (Apologize). The appendix was a bit of a rush job. You got it in your description.

    Decomposition is trickier. It's not spliterator. I think they phrased this objective poorly. The actual objective says "including decomposition operation and reduction operation in streams". And I think they meant that you "decompose" the stream while reducing it. (Yeah, I know). I've looked online and most references to decomposition are about exam objectives and then they then talk about reduction.

    If you want to learn about spliterator of streams beyond the exam "Java 8 for the Really Impatient" is excellent. But you don't need it for the exam.
     
    John S. Green
    Greenhorn
    Posts: 10
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you, Jeanne!  I'm glad my description of PathMatcher is correct and hopefully useful to others.  As for decomposition, I had the same experience as you searching for it on the Internet -- it ended up as a discussions on reduction.  I should have mentioned this.
     
    John S. Green
    Greenhorn
    Posts: 10
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I noticed a few more subtleties in the Javadoc of FileSystem.getPathMatcher:

  • "A FileSystem implementation supports the "glob" and "regex" syntaxes, and may support others." - so doesn't just have to be glob or regex in general, even if it's probably only those that are currently implemented (I checked WindowsFileSystem and ZipFileSystem)!
  • "For both the glob and regex syntaxes, the matching details, such as whether the matching is case sensitive, are implementation-dependent and therefore not specified." - so the pattern's case-sensitivity can vary!

  • I tested with Windows and the pattern was case-insensitive.  I guess that with Posix systems it will be case-sensitive.
     
    Jeanne Boyarsky
    author & internet detective
    Marshal
    Posts: 37896
    594
    Eclipse IDE Java VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    John S. Green wrote:T As for decomposition, I had the same experience as you searching for it on the Internet -- it ended up as a discussions on reduction.  I should have mentioned this.


    Yeah. I searched because I was curious if others interpreted it the same way we did!
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!