List All Files in Directory
Files.list
Method Return a lazily populated Stream, the elements of which are the entries in the directory.
We Can use the stream operations to find Specific Files, List file matching certain criteria, List filenames in sorted order etc.
Example 1: List All Files in Directory
1 |
|
Example 2: List All Files in Directory Starting with A
1 |
|
Example 3: List Files Only
1 |
|
Example 4: List Directory Only
1 |
|
Example 5: List Hidden files Only
1 |
|
Note
Files.list
Method Return a lazily populated Stream for the directory.
It does not return Stream for the nested directory. For that, we Can use File.walk
. Will discuss that in next chapter.