public class 练习4 {
/**
4. 读取txt文档中名字,名字以空格 空开,统计名字出现的次数,
* @throws IOException
*/
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new FileReader("ccc.txt"));
String s=null;
String s1=" ";
int b=0;
while((s=br.readLine())!=null){
String []s3=s.split(s1);
b=b+s3.length;
}
System.out.println(b);
}
}
|