Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
1
11
12
13
14
15
16
17
18
19
20
21
22
23
24
30
// {
Path directory = Paths.get("/");
// Method 1: get the files in the given directory
Files.list(directory)
.filter(Files::isDirectory)
.forEach(System.out::println);
// Method 2: recursively run through the tree (at a maximum depth of 2)
Files.walk(directory, 2)
.filter(Files::isRegularFile)
.forEach(System.out::println);
//{
Enter to Rename, Shift+Enter to Preview
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content