Write a java program that compute the frequency of each word in the file Task: Implementing Word Counter Problem description: Given a text file, you need to compute the frequency of each word in the file. WordFrequency word: String count: int +WordFrequency(String) +getWord): String +getCount): int +incCount): void TestClass +static main(String[): void / /implements ArrayList of // WordFrequency The WordFrequency class stores the frequency (count) of each word. Solution import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; class FileIO { public static void main (String[] args) throws IOException { readTextFileInBinaryMode (\"T.txt\"); } public static void readTextFileInBinaryMode (String fileName) { FileReader fileReader = null; LinkedHashMap <String, Integer> wordcount = new LinkedHashMap <String, Integer> (); try { File file = new File (fileName); fileReader = new FileReader (file); int ch = -1; boolean prevCharIsNotSpace = true; StringBuilder strBuild = new StringBuilder (); while ((ch = fileReader.read ()) != -1) { if (ch == 32) { if (prevCharIsNotSpace) { Integer freq = wordcount.get (strBuild.toString ()); wordcount.put (strBuild.toString (), (freq == null ? : freq + 1)); } prevCharIsNotSpace = false; continue; } if (prevCharIsNotSpace == false) strBuild = new StringBuilder (); strBuild.append ((char) ch); prevCharIsNotSpace = true; } } catch (Exception e) { System.out.println(\"Exception occurs\"+e.getException()); } //sorting List <Map.Entry <String, Integer>> list = new ArrayList <Map.Entry <String, Integer>> (); for (Map.Entry <String, Integer> entry : wordcount.entrySet ()) { System.out.println (entry.getKey () + \" \" + entry.getValue ()); list.add (entry); } Collections.sort (list, new MapComprator ()); for (Map.Entry <String, Integer> entry : list) { System.out.println (entry.getKey () + \" \" + entry.getValue ()); } } } class MapComprator implements Comparator <Map.Entry <String, Integer>> { public int compare (Entry <String, Integer> o1, Entry <String, Integer> o2) { return (o2.getValue ().compareTo (o1.getValue ())); } } .