Source of Driver.java


  1: import java.util.Scanner;
  2: import java.io.File;
  3: import java.io.FileNotFoundException;
  4: /**
  5:    A driver that demonstrates the class FrequencyCounter.
  6:    
  7:    @author Frank M. Carrano
  8:    @author Timothy M. Henry
  9:    @version 4.0
 10: */
 11: public class Driver
 12: {
 13:    public static void main(String[] args) 
 14:    {
 15:       FrequencyCounter wordCounter = new FrequencyCounter();
 16:       String fileName = "Data.txt"; // Or file name could be read
 17: 
 18:       try
 19:       {
 20:          Scanner data = new Scanner(new File(fileName));
 21:          wordCounter.readFile(data);
 22:       }
 23:       catch (FileNotFoundException e)
 24:       {
 25:          System.out.println("File not found: " + e.getMessage());
 26:       }
 27: 
 28:       wordCounter.display();
 29:    }  // end main
 30: }  // end Driver
 31: