EXPERIMENT-13
13. Write a Java program to list all the files in a directory including the files present in all
its sub directories.
Program:-
import [Link].*;
public class FileDisplay
{
public static void main(String args[])
{
File DirName=new File("C:\\Users");
displayContents(DirName);
}
public static void displayContents(File dir)
{
try{
File[] list=[Link]();
for(File file:list)
{
if([Link]())
{
[Link]("directory:"+[Link]());
displayContents(file);
}
else
{
[Link]("file:"+[Link]());
}
}
}
catch(IOException ie)
{
[Link]();
}
}
}