Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Get words from a .txt or .htm file

  Asked By: Dylan    Date: Dec 09    Category: Java    Views: 1123

I want to make a little program that open a .txt or .htm file and
count the words that are in it and then keep them in order in a new
How can I make this?



2 Answers Found

Answer #1    Answered By: Ziza Mizrachi     Answered On: Dec 09

Well, the process I would take is to first read the whole file  into a
bufferedreader. Then go through line by line. On each line, I would use
apache's regexp package and the RE.matchAt method to find words  using regular
expressions (you can match on word boundaries). I'd add each word to an
arraylist. When I finished processing the file, I would write all my words to
the new file and output the size of the arraylist.

Answer #2    Answered By: Fairuzah Alam     Answered On: Dec 09

well I just wanted to thank Dustin (thanks for the ideas), Adam
(Thank you so much for your support) & neowhere (now I got
everything clear with the stringtokenizer Thanks for the URL )

Didn't find what you were looking for? Find more on Get words from a .txt or .htm file Or get search suggestion and latest updates.