方法一
import java.io.*;
import java.util.*;
public class Test{
public static void main(String args[])throws Exception{
File file = new File("d:\\src\\Test.java");
display(file);
}
public static void display(File file)throws Exception{
BufferedReader br = new BufferedReader(new FileReader(file));
String line = null;
TreeMap tm = new TreeMap();
while((line=br.readLine())!=null){
line.toLowerCase();
String reg1 = "\\s+";
String reg2 ="^[a-zA-Z]\\w*";
String str[] = line.split(reg1);
for(String s: str){
if(s.matches(reg2)){
if(!tm.containsKey(s)){
tm.put(s,1);
}
else{
tm.put(s,tm.get(s)+1);
}
}
}</