import java.util.*; import java.io.*; public class Chad { public static void main(String[] args) { double sum = 0.; // sum accumulates the sum of all numbers int numofitems = 0; // counts the number of items double value; // value is the number read in each time String filename; // name of the file being read String NextLine; try { BufferedReader stdin = new BufferedReader( new InputStreamReader(System.in)); System.out.println("\nPlease enter the name of the data file: "); System.out.println("Suggestion: Lab4.dat "); filename = stdin.readLine(); FileReader reader = new FileReader(filename); double[] array; // initialize array BufferedReader in = new BufferedReader(reader); String inputLine; int cnt = 0; while ((inputLine = in.readLine()) != null) { System.out.println("Counting> " + inputLine); cnt++; } array = new double[cnt]; //Johnny Modification int j = 0; String line = ""; FileReader fin = new FileReader(filename); BufferedReader bin = new BufferedReader(fin); while ((line = bin.readLine()) != null) { System.out.println("Add to element> " + line); array[j] = Double.parseDouble(line); j++; } for ( int i = 0; i < array.length; i++) { System.out.println("Element Content>" + array[i]); } //End Johnny Modification reader.close(); // close the input file } // end of the try catch (FileNotFoundException e) { System.out.println("File not found"); System.exit(1); } catch (IOException e) { System.out.println( "Error in write file" ); System.exit(1); } } // end of main } // end of class