public class driver
{
private static ArrayList<String> arrayList ;
TownBankRecord TBR = new TownBankRecord();
ArrayList<Record> TBList = new ArrayList<Record>();
public void getDate()
{
try
{
BufferedReader br = new BufferedReader (new FileReader ("data/bank-data.csv"));
String line= " ";
int tokenCount=0;
//BankRecord bank= new BankRecord();
while((line=br.readLine())!=null)
{
if (!line.equals(","))
{
StringTokenizer st = new StringTokenizer(line,",");
while (st.hasMoreTokens())
{
arrayList.add(st.nextToken());
tokenCount++;
}
}
if (tokenCount==11)
{
er = new TownBankRecord(arrayList);
TBList.add(er);
tokenCount=0;
}
}
}
catch (FileNotFoundException ex)
{
System.out.println(ex.getMessage());
}
catch (IOException e)
{
System.err.println("Caught IOException: "
+ e.getMessage());
}
}
}
The above code reads from a CSV file. I have used a tokenizer which gets the tokens from each line and then transfers them to an ArrayList of Strings. The ArrayList is then transfered to an object er of TownBankRecord which then finally transfered to TBlist (Record datatype). I have the following error for er:
cannot find symbol
symbol: variable er
location: class nidhin.driver.
Any ideas?
You never declare
eras a variable. You also don’t use the class field you do declare,TBR. Are these intended to be the same?