List all files and folders in a folder in Java

In this tutorial, we will see How to list all files and folders in a folder in Java.

File class in java.io package provides listFiles() method to list files in a folder. The listFiles() method returns an array of files in the directory. Let’s see the usage of listFiles() method with an example.

Example:

Output:

You can also learn about:

Related posts

Leave a Comment