The list() method from Java IO API returns an array of pathnames that could contain files and directories. There is no guarantee that the name strings in the resulting array will appear in any specific order. The array will be empty if the directory is empty.
2. Method signature
- method does not take any parameter
- array of the pathnames
- SecurityException - when we do not have access to the file or directory
3.1. The code snippet prints the names of folders and files in
In this article, we presented
list() method that could be used to list the directory content. This method returns only names so to get File object from returned resources we should concatenate the root directory with that names.