import java.io.*;
class SumFile {
public static void main (String[] args) throws Exception {
// Make a connection to the data file "numbers.dat"
FileReader fr = new FileReader("numbers.dat");
BufferedReader br = new BufferedReader(fr);
// Initialize sum
int sum = 0;
// Read the first String from the file
String inputString = br.readLine();
// while the end of the file has not been reached...
while (inputString != null) {
// ...convert the String to a number
int num = Integer.parseInt(inputString);
// ...add the number to the total so far
sum = sum + num;
// ...read the next line
inputString = br.readLine();
}
// Display the final total
System.out.println("Sum = " + sum);
} // end main
} // end class