is this a good class scanner reader that reads any kind of file. It will store your
Question:
is this a good class scanner reader that reads any kind of file. It will store your flight information into a 1D array of Flight? how would i pass the name of the file from the main so it correctly makes the list?
public class CSVREADER{
String path;
Scanner in;
File fileObj;
int getFileSize(String s){
int size;
while(this.in.hasNextLine()){
this.in.nextline();
size++
}
return size
}
void csvReader(String path){
this.path = path;
this.fileObj = new File(path);
this.in = new Scanner(fileObj);
}
public Flight[] getFlights(String f) {
ArrayList tempList = new ArrayList<>();
while (in.hasNextLine()) {
String line = in.nextLine();
tempList.add(line);
}
String[] tempArray = tempList.toArray(new String[0]);
Flight[] flightList = new Flight[tempArray.length];
for (int i = 0; i < tempArray.length; i++) {
flightList[i] = new Flight(tempArray[i]);
}
return flightList;
}
}
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill