• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is there a better way to store big text files instead of using hash map/set ?  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Hash set that contains a text file content
this is how I added the text file's values to the Hash Set

and I used this code to count number of occurrences for each word:
          
My text file is big and can not be stored in a normal list this why I used hash map
The problem Is Hash set/map does not allow duplicate values and It shows the count of all words as 1
any help? 
 
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you just want to count the occurrences of all words in a text file?

You can easily do this using the Map.merge() method:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!