Read all files and filenames in a folder using java
by THavamani[ Edit ] 2013-08-27 18:54:44
I want to read all the files and file names in a folder through Java
public void listFilesForFolder(final File folder) {
for (final File fileEntry : folder.listFiles()) {
if (fileEntry.isDirectory()) {
listFilesForFolder(fileEntry);
} else {
System.out.println(fileEntry.getName());
}
}
}
final File folder = new File("/home/you/Desktop");
listFilesForFolder(folder);