You could do it by doing the following:
split the
currentLine
using split method:String[] nums = currnetLine.split("\\s+");
loop over the
nums
and parse each elements toint
then add it to asum
variableint sum = 0; for (int i = 0; i < nums.length; i++) { int num = Integer.parseInt(nums[i]); if(num != -1) { sum += num; } }
Finally calculate the average.
sum/(nums.length - 1);// -1 because you need to execlude the -1 at the end of your line