How to Print number of occurrences of each word of a text file along with the word by reading the file.
For example, A file with name "test.txt" having some contents suppose, "Lion is the king of Forest. Lion runs slower than a tiger"
first read the file "test.txt". by using any stream classes of java.
Print each word along with number of occurrences of that word. For example., In this file "Lion" is twice times so output should be like-> Lion:2
Similarly, king appears only one time so it should print like-> king:1.
- Can it be done by HashMap ? if So please solve this.