I have a folder structure like : E:\Test. Inside it I have many sub-folders like FolderA, FolderB, FolderC, etc.
I want to have a java program that will list down all the subfolders and the report files inside the subfolders. How can I achieve this? Using the below snippet, I can access the different folders inside the E:\Test directory, but files inside the subfolders aren't appearing.
public static void main(String args[]){
File directoryPath = new File("E:\\Test\\");
File folderPath [] = directoryPath.listFiles();
System.out.println("List of files and folders in the directory : ");
for(File file : folderPath){
System.out.println("Folder Name Is : " +file.getAbsolutePath());
System.out.println("Files under the folderpath are : " +file.listFiles());
System.out.println(" " );
}
}