Which two try statements, when inserted at line 11, enable you to print files with the extensions.java, .htm, end and .jar.

Given the code fragment:
<code>
public static void main(String[] args) {
Path dir = Paths.get(“d:\\company”);
// insert code here. Line **
for (Path entry: stream) {
System.out.println(entry.getFileName());
}
} catch (IOException e) {
System.err.println(“Caught IOException: ” + e.getMessage());
}
}
</code>
Which two try statements, when inserted at line 11, enable you to print files with the extensions.java, .htm, end and .jar.

Given the code fragment:
<code>
public static void main(String[] args) {
Path dir = Paths.get(“d:\\company”);
// insert code here. Line **
for (Path entry: stream) {
System.out.println(entry.getFileName());
}
} catch (IOException e) {
System.err.println(“Caught IOException: ” + e.getMessage());
}
}
</code>
Which two try statements, when inserted at line 11, enable you to print files with the extensions.java, .htm, end and .jar.

A.
try (DirectoryStream<path> stream =Files.newDirectoryStream(dir, “*.{java, htm, jar}”)) {

B.
try (DirectoryStream<path> stream =Files.newDirectoryStream(dir, “*.[java, htm, jar”] }} {

C.
try (DirectoryStream<path> stream =Files.newDirectoryStream(dir, “*.{java*, htm*, jar*}”}} {

D.
try (DirectoryStream<path> stream =Files.newDirectoryStream(dir, “**.{java, htm, jar}”)) {

Explanation:
Reference: The Java Tutorials Finding Files What Is a Glob?



Leave a Reply 0

Your email address will not be published. Required fields are marked *