How to count the number of times each word appears and store in table?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Teri Yeoh
    New Member
    • Aug 2010
    • 1

    #1

    How to count the number of times each word appears and store in table?

    Hi,

    Please forgive me, I'm new to java.

    I've got a hunk of text. I want to count the number of times each word appears. I understand that I should store the keys & values in a hashmap/hashtable. How should I go about doing this?

    Thanks so much!
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Please forgive me, I'm new to java.
    We all were new once up on a time. :)

    Coming back to problem. I suspect you are trying to read the input string from the file. tokenize the input string on space then compare the tokenized strings with the string you need to compare. If they are same increment the count.

    This may not suit the large file with hundreds of line of text.

    Regards
    Dheeraj Joshi

    Comment

    Working...