Why do you need to store all the lines? Couldn't you just maintain the average of the numbers in a variable.
For example,
create a total & amount variable (for the average... average = total/amount)
double total =0;
double amount=0;
//for each line in the file
while ((line = input.readLine()) != null)
{
//tokenize the line
StringTokenizer tokenizer = new StringTokenizer(line, ",");
//if there are 3 tokens in the line
if( tokenizer.countTokens() == 3)
{
//get 1st token in line
String str = tokenizer.nextToken();
//get 2nd token in line
int num1 = Integer.parseInt(tokenizer.nextToken().trim());
//get 3rd token in line
int num2 = Integer.parseInt(tokenizer.nextToken().trim());
//add numbers to total
total += num1 + num2;
//increment amount
amount++;
}
}
//show average
System.out.println("Average is: " + total/amount);
You should give more information about your project so a better answer can be given. Hope the above helps.
For more help, www.NeedProgrammingHelp.com