• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting number of same word count  RSS feed

 
sigamala viswanath
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need help of one program,
i.e how can i get the number of same words count from given file.

Thanks,
Viswanath S
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15865
81
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here are some hints to get you started - you'll have to write the program yourself:

Write a program that opens and reads the file line by line. You can use BufferedReader to read a file line by line.

Break up each line into words (how you do that, depends on what your exact definition of a "word" is). Probably you want to use java.util.Scanner (or StringTokenizer) to do this.

Keep track of how many times each word was encountered. A good data structure for this would be a Map, with words as keys and counters as values.

Finally, after the file is read completely, print out the content of the Map.
[ May 18, 2006: Message edited by: Jesper Young ]
 
sigamala viswanath
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Jesper, i got the program it working fine.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!