黑马程序员技术交流社区

标题: 读取txt文档中名字,名字以空格 空开,统计名字出现的次数, [打印本页]

作者: 你好世界    时间: 2016-1-23 22:50
标题: 读取txt文档中名字,名字以空格 空开,统计名字出现的次数,
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);
        }

}







欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2