/** * This is a driver program for the WordCounter class. * * @author Clark Olson * @version 1.0 */ import java.util.Scanner; import java.io.FileInputStream; import java.io.FileNotFoundException; public class WordTester { /** * main: open the text file and process it using the WordCounter class * pre: The file "test.txt" must exist in the program directory * post: Output the number of occurrences of "the", "not", "memory", and "program" */ public static void main(String[] args) { Scanner wordFile = null; // Try to open the file try { wordFile = new Scanner(new FileInputStream("test.txt")); } catch (FileNotFoundException e) { System.out.println("File not found or not opened."); System.exit(0); } // Count and display the words in the file WordCounter theWords = new WordCounter(); theWords.countOccurrences(wordFile); theWords.displayTable(); } }