sponsored ads

how to find a repeated word from a file in java

sponsored ads

    Who know java well? I want to ask how to find a repeated word from a file using java, who can give me the code? Thank you!

Asked Sep, 01 2010
add commentflag 

sponsored ads

answer this question

Try "(\\w)\\1+"

The \\w matches any word character (letter, digit, or underscore) and the \\1+ matches whatever was in the first set of parentheses, one or more times. So you wind up matching any occurrence of a word character, followed immediately by one or more of the same word character again.

Answered Nov, 12 2010
vote up 0 vote down

Use a HashMap instead of a HashSet and this class as the value:

class Counter {
public int frequency;
}
addWord() then looks like this:

public void addWord (String word) {
Counter c = map.get (word);
if (c == null) {
c = new Counter ();
map.put(word, c);
}
c.frequency ++;
} Answered Dec, 27 2010
vote up 1 vote down

Hi,

Simply  press CTRL  F to bring up the Find box. Type the sentence, Enter.

MS word will search it for you.

Answered Oct, 07 2010
vote up 0 vote down

Your Answer

community wiki:

The Verified Code is to stop spamming. It will be hidden once your reputation reached 100.
or
Create one

Options

sponsored ads

Download related software from AFC

HTML+Java 0.5.13022.28751

Last Updated: May 23, 2011
License:
Filesize: 282KB

Continue to downloadPower by Afreecodec.com