nerdexam
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

1Z0-804 question #149 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)
  • A
    73% (43)
  • B
    10% (6)
  • C
    17% (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.

Full 1Z0-804 Practice