import java.io.*; class Numbers2a { // Read a number of integers from a file named as a command line // argument and store them in an array. static final int MAXNUMS = 10; public static void main (String[] args) throws IOException { int [] data; int count=0; BufferedReader reader=null; double average; if(args.length!=1) { System.out.println("Must have exactly one file name as argument"); System.exit(1); } try { reader = new BufferedReader(new FileReader(args[0])); } catch(FileNotFoundException e) { System.out.println("No file '"+args[0]+"' found"); System.exit(2); } data = new int[MAXNUMS]; try { for(;;) data[count++]=Text.readInt(reader); } catch(EOFException e) {} catch(ArrayIndexOutOfBoundsException e) { System.out.println("Cannot take more than "+MAXNUMS+" numbers"); } count--; System.out.println("The numbers entered were:"); NumberOps.printall(data,count); } }