Find out words occurrences in a file

In the previous post, we have seen how to find common elements among 2 unsorted arrays. In this post, we will see how to get the count of same word occurrences in a file.

Find out words occurrences in a file:

There are few steps given below that need to be followed.

  • Create a object for file
  • Read it using Buffered Reader
  • Create a Map of String and Integer as key and value respectively
  • Keep increasing the counter if key matches more than once
  • Display keys and their values

is– 3
are– 2
how– 2
your– 1
doing– 1
book– 1
you– 2
house– 1
dog– 1
my– 2
this– 3
Find common elements among two unsorted arrays
Database connection in Java
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *