Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Path dir = new File(pathname).toPath();
- try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
- for (Path file: stream) {
- System.out.println(file.getFileName());
- }
- } catch (IOException | DirectoryIteratorException x) {
- // IOException can never be thrown by the iteration.
- // In this snippet, it can only be thrown by newDirectoryStream.
- System.err.println(x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement