Question 4
Which method or methods should you implement to create your own implementation of the java.nio.file.PathMatcher interface?
matches(Path), fails(Path)
matches(Path), fails(Path), enable(boolean)
matches(Path), fails(Path), setPreferred (String)
Correct answer: A
Explanation:
The interface PathMatcher is an interface that is implemented by objects that perform match operations on paths.The single method for this interface is matches:boolean matches(Path path)Tells if given path matches this matcher's pattern.Parameters:path – the path to matchReturns:true if, and only if, the path matches this matcher's pattern.Reference: java.nio.file.PathMatcher
The interface PathMatcher is an interface that is implemented by objects that perform match operations on paths.
The single method for this interface is matches:
boolean matches(Path path)
Tells if given path matches this matcher's pattern.
Parameters:
path – the path to match
Returns:
true if, and only if, the path matches this matcher's pattern.
Reference: java.nio.file.PathMatcher