<<< File info | Index | Topics to discuss >>> |
Code that displays the files in a directory
if ( Files.exists( dirPath ) && Files.isDirectory( dirPath ) ) { System.out.println("Directory: " + dirPath.toAbsolutePath()); System.out.println("Files: "); DirectoryStream<Path> dirStream = Files.newDirectoryStream(dirPath); for (Path p: dirStream) { if (Files.isRegularFile(p)) { System.out.println(" " + p.getFileName()); } } }
<<< File info | Index | Topics to discuss >>> |