Saturday, December 29, 2007
getting the list of files of a folder
/**
* returns the list of files of a given directory
*
* @param listOfFiles
*/
public static void getListOfFilesOfFolder(File directory,
List<File> listOfFiles) {
File[] fileList = directory.listFiles(FileFilter.getInstance());
for (int iFile = 0; iFile < fileList.length; iFile++) {
File oneFile = fileList[iFile];
if (!oneFile.isDirectory()) {
listOfFiles.add(fileList[iFile]);
} else {
getListOfFilesOfFolder(oneFile, listOfFiles);
}
}
}
//the FileFilter class is a class that implements the interface FileNameFilter
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment