Possible Duplicate:
Recursively list files in Java
Java program to list all files in a drive along with the path of that file.....is it possible? how?
Possible Duplicate:
Recursively list files in Java
Java program to list all files in a drive along with the path of that file.....is it possible? how?
I'm not sure if I understood you correctly, File has a method list. If you'd like to use recurrent searching, you might be interested in this tutorial.
use this:
public class Main {
public static void main(String[] args) {
File[] roots = File.listRoots();
for (File root : roots) {
showFolderRecursively(root);
}
}
private static void showFolderRecursively(File root) {
System.out.println(root.getAbsolutePath());
File[] files = root.listFiles();
for (File file : files) {
if ( file.isFile() ) {
System.out.println(file.getAbsolutePath());
} else {
showFolderRecursively(file);
}
}
}
}