// This is a sample program that reads numbers from a file, reporting the sum // of each line of the input file. import java.util.*; import java.io.*; public class SumFile { public static void main(String[] args) throws FileNotFoundException { Scanner input = new Scanner(new File("numbers.txt")); while (input.hasNextLine()) { String line = input.nextLine(); Scanner data = new Scanner(line); double sum = 0.0; while (data.hasNextDouble()) { double next = data.nextDouble(); sum = sum + next; } System.out.println("line sum = " + sum); } } }