Description
Write a program that will read from a file and display to the console all the words in the file in
alphabetical order along with the number of times each word appeared in the file. For example, if the
input file is:
This is an example, of an input file
for project four, as an example.
The output to the console would be:
an – 3
example – 2
file – 1
for – 1
four – 1
input – 1
is – 1
of – 1
project – 1
This – 1
To get the individual words from each line of the file use a regular expression (perhaps with the split
method of class String) as shown in lecture. Note that the input file may contain reasonable punctuation
marks separating the words.
Use a TreeMap to store the words and their counts (that is, TreeMap <String,Integer>)
You will need to use the wrapper class Integer to hold the count of the words as TreeMaps do not store
primitives.
Allow the user to select the input file using a JFileChooser.
Since this project can be done with one class, you do not need to create a jar file. You can submit the
file Project4.java to Blackboard. Make sure you upload the correct file by the due date (which is also the
cutoff date) as there will be no opportunities for resubmission of projects.