Displaying directory contents in Java

For listing a directory content in java we use File class and use isDirectory() method to check whether it is directory or not.
if directory then we use listFiles().