What are the possible results of executing the following code? (Choose all that apply.)
1: Path path = Paths.get("data.txt"); 2: try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(path)) { 3: for (Path entry: directoryStream) 4: System.out.println(entry.getFileName()); 5: }
A,E.
First off, the code compiles without issue, so B and C are incorrect.
Next, it is possible for a directory to have an extension in the name, so A is correct, albeit uncommon.
D is an incorrect answer, and it relates to threading, not a DirectoryStream walk process.
E is correct, at least tangentially, because NotDirectoryException and NoSuchFileException extend IOException.