01: import java.io.FileNotFoundException;
02: import java.io.IOException;
03: import java.util.Scanner;
04: 
05: public class DataSetTester
06: {
07:    public static void main(String[] args)
08:    {
09:       Scanner in = new Scanner(System.in);
10:       DataSetReader reader = new DataSetReader();
11:       
12:       boolean done = false;
13:       while (!done) 
14:       {
15:          try 
16:          {
17:             System.out.println("Please enter the file name: ");
18:             String filename = in.next();
19:             
20:             double[] data = reader.readFile(filename);
21:             double sum = 0;
22:             for (double d : data) sum = sum + d; 
23:             System.out.println("The sum is " + sum);
24:             done = true;
25:          }
26:          catch (FileNotFoundException exception)
27:          {
28:             System.out.println("File not found.");
29:          }
30:          catch (BadDataException exception)
31:          {
32:             System.out.println("Bad data: " + exception.getMessage());
33:          }
34:          catch (IOException exception)
35:          {
36:             exception.printStackTrace();
37:          }
38:       }
39:    }
40: }