Linkbar

>> Thursday, July 9, 2015

In this tutorial, you will learn How to Find Maximum Occurrence of Words or repeated words from given Text File.
In the earlier post we have gone through How to read a file using BufferedReader and Scanner.This would give you a basic idea to read a file through the Streams. And the related post to this current program best way to find repeated characters from a String also helpful to understand the maximum repeated words from the given text file. Here i am using BufferedReader and FileInputStream to read a file, if the file does not exists this throws an exception FileNotFoundException.

Here are the steps to write the program:

Write a method getWordCount to count the number of words in a given text file.

Create a Map with key value as String, Integer to Store words and its count.

Create sorByValue method with the return type List(contains map objects) to sort by the map values.