// CS7 // this program opens a text file specified at the command line // and prints out the number of words it finds in that file. import tio.*; class WordCount { public static void main (String [] args) { if (args.length < 1) { System.out.println("Please specify an input file."); System.exit(1); // quits with an error signal to OS } ReadInput in = new ReadInput(args[0]); int count=0; while (in.hasMoreElements()) { String word = in.readWord(); System.out.print("."); count++; } System.out.println(); System.out.println(args[0] + " contains " + count + " words."); } }