1. Overview
In this tutorial, We'll be learning the
Files API walk() method in java 8. walk() method is part of the Files class and java.nio.file package.
This method is used to walk through any given directory and retrieves Stream<Path> as the return value. This method traverses through all its subdirectories as well.
API Description:
Return a Stream that is lazily populated with Path by walking the file tree rooted at a given starting file. The file tree is traversed depth-first, the elements in the stream are Path objects that are obtained as if by resolving the relative path against start.
Note: This method must be used within a try-with-resources statement.
In this article, We'll see its syntax and example programs on how to list all the files in the directory, list directories and specific file patterns such as .csv or file name contains 'Match' word.