Oracle
1Z0-804 · Question #149
Given the code fragment: Which two try statements, when inserted at line ***, enable you to print files with the extensions.java, .htm, and.jar.
The correct answer is A. try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir,"*.{java,htm,jar}")){ D. try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir,"**.{java,htm,jar}")) {. ". {java,htm,jar} and "*. {java,htm,jar} will match any file with file endings java, htm, or jar.
NIO.2
Question
Given the code fragment:
Which two try statements, when inserted at line ***, enable you to print files with the extensions.java, .htm, and.jar.
Exhibit
Options
- Atry (DirectoryStream<Path> stream = Files.newDirectoryStream(dir,"*.{java,htm,jar}")){
- Btry (DirectoryStream<Path> stream = Files.newDirectoryStream(dir,"*. [java,htm,jar]")) {
- Ctry (DirectoryStream<Path> stream = Files.newDirectoryStream(dir,".{java,htm*,jar*}")) {
- Dtry (DirectoryStream<Path> stream = Files.newDirectoryStream(dir,"**.{java,htm,jar}")) {
How the community answered
(59 responses)- A73% (43)
- B10% (6)
- C17% (10)
Explanation
"*. {java,htm,jar} and "**. {java,htm,jar} will match any file with file endings java, htm, or jar.
Topics
#DirectoryStream#glob patterns#file filtering#path matching
Community Discussion
No community discussion yet for this question.
