Given the code fragment:
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());
}
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?