I wrote a piece of code that appends the contents of all CSV files into a list. Compiling this program generates a "cannot find symbol" error at the line '''Iterator iter = full_files.iterator();'''
I checked my declarations and everything seems to be fine. I have declared and initialised full_files in the previous line.
public ArrayList<String[]> readCSV(File FDir) throws IOException {
File[] files = FDir.listFiles();
File F = files[0];
ArrayList<String[]> all_list = new ArrayList<>();
ArrayList<String[]> list = new ArrayList<>();
// Creating a file to point to the "Full" directory
File FullDir = new File(F.getParent() + "/Full/");
File[] full_files = FullDir.listFiles();
Iterator<File> iter = full_files.iterator();
// Iterating through the files in "Full"
while(iter.hasNext()) {
File file = iter.next();
if(GetFileExtension.get(file).equals(".csv")) {
list = CSVHandler.readCSV(file);
all_list.addAll(list);
}
}
// Checking if the file outside "Full" is a CSV
if(GetFileExtension.get(F).equals(".csv")) {
list = CSVHandler.readCSV(F);
all_list.addAll(list);
}
return all_list;
}
This is the error I get during compilation.
shared/utilities/main.java:82: error: cannot find symbol
Iterator<File> iter = full_files.iterator();
^
symbol: method iterator()
location: variable fast of type File[]
1 error