In this section, you will study how to retrieve all the files and folders from the specified directory. In the given example, we are providing the directory 'C:\\" to the constructor of class File.
file.listFiles()- This method returns an array of files and folders present in the specified directory with their pathname.
file.length()- This method returns the length of the provided directory.
files[fileInList]. toString- This will display all the files of directory on the console.
Here is the code of GetFileList.java
Output will be displayed as:
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: October 24, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles