I would go as follows:
Create a BufferedReader:
// Google "Java Reading from a File
// There are various ways to set up the buffer
BufferedReader buf = new BufferedReader_To_Read_From_A_File;
// Declare a HashMap (checkout HashMap in the Java Doc
// online on the Sun website
HashMap storage = new HashMap();
while(buf.readLine() Still has Lines)
String str = buf.readLine();
// Read word by word separated by " "
StringTokenizer tokenizer(str, " ");
// Make up for all punctuations
while(tokenizer.hasMoreTokens())
String str2 = tokenizer.nextToken();
if(str2 has ","){
getRid of "," in str2
}else if(str2 has "."){
getRid of "." in str2
}
//... etc
// place str2 in storage and increase its
// value
int i = 0;
Integer my_int = new Integer(1);
if(storage_contains_str2){
my_int = new Integer(storage.get(str2))
i = my_int.intValue();
i = i +1;
my_int = new Integer(i);
}
storage.put(str2, my_int);
}// end while tokenizer
}// finished readingLines
Now obviously this is very Algorithmic so you can
fill in the blanks and turn this into proper Java
Syntax your self. As mentioned, go through the
Java API (Java Doc), look at what methods you can
use for HashMap and Google reading from a File.
Good luck.
Spike