import java.io.IOException;
import java.nio.*;
import java.util.stream.Stream;
try {
Stream<Path> files = Files.walk(Paths.get("/path/to/directory"));
// Do something with the files such as files.forEach(System.out::println);
files.close();
} catch (IOException e) {
// directory not found or invalid permissions
}
List all files in a directory
List all the files in a directory using Java 8 methods
0 Comments
Add Comment
Log in to add a comment