Folder Loading and Cleaning
in
Programming Questions
•
3 months ago
Hi all.
I use the following code to load the files of a folder. Because I want to load only specific file types, I try to see how I can clean the file list and get only the necessary files I want. The following code does not work. Any help is appreciated!
String path = "/Users/Desktop/dataFolder/";
String[] filenames = listFileNames();
String[] listFileNames() {
File file = new File(path);
if (file.isDirectory()) {
String names[] = file.list();
for (int i=0; i<names.length; i++) {
if (names[i].toLowerCase().endsWith(".csv")) {
println(names[i]);
}
}
return names;
}
else {
return null;
}
}
1