Given a directory (folder) and we have to traverse its all files using java program.
Example:
Input:
Enter path: 'E:\Java'
(Java folder in 'E' drive)
Output:
About to traverse the directory: JAVA
About to traverse the directory: 1 Nov
Visiting file:ChristmasTree.java
Visiting file:Find Files in Zip File.docx
Finished with the directory: 1 Nov
About to traverse the directory: 2 Nov
Visiting file:Combine Path.docx
Visiting file:CombinePath.java
Finished with the directory: 2 Nov
About to traverse the directory: 3 Nov
Visiting file:Check absolute path.docx
Visiting file:CheckAbsolutePath.java
Finished with the directory: 2 Nov
Program to traverse all files from a directory in java
Output
Enter path here : E:/JAVA About to traverse the directory: JAVA About to traverse the directory: 1 Nov Visiting file:ChristmasTree.java Visiting file:Find Files in Zip File.docx Finished with the directory: 1 Nov About to traverse the directory: 2 Nov Visiting file:Combine Path.docx Visiting file:CombinePath.java Finished with the directory: 2 Nov About to traverse the directory: 3 Nov Visiting file:Check absolute path.docx Visiting file:CheckAbsolutePath.java Finished with the directory: 2 Nov
need an explanation for this answer? contact us directly to get an explanation for this answer