This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I'm trying to read in words from a file and then put those words into and array and sort the array, I kinda have a program but it isn't working can some one help me out with it, It would be nice to see some source code. I'm new to java and am having problems with the syntax and object orintation of the language. Anyways some help would be nice
I knew I was a vim addict when I started editing my emacs with vim
So all you need is read a text file, split it in words, and end up with a sorted array of words?Or perhaps you are interested in the unique words in your document? In that case, a Set is more appropriate.If you do want unique words, but not a Set, tryAnd so forth. The combination of regular expressions and the Collections framework is good fun although still not as much as Perl. - Peter
Peter den Haan
Joined: Apr 20, 2000
I realised you may want to know the frequency of the words as well. The following code is a bit dirty, so don't show it to anyone as-is -- it will return a sorted list of words, each stating how many times it occurred in the source text:It doesn't return an array, it actually returns a Collection of Count objects. If you print them (which calls toString() on the objects) you'll get the promised list.HTH - Peter [ March 03, 2003: Message edited by: Peter den Haan ]