someone can help me with code? How to search in text file any word and count how many it were repeated?
For example test.txt:
hi
hola
hey
hi
bye
hoola
hi
And if I want to know how many times are repeated in test.txt word "Hi" program must say "3 times repeated"
I hope you understood what I want, thank you for answers.
Apache Commons - StringUtils.countMatches()
try using java.util.Scanner.
Try it this way with
Pattern
andMatcher
.now iterate through this map to get the count for each word using each word as a key to the map values