26 查看文件内容有多少行?

public class Count {
    public static void main(String[] args) throws IOException {
        String filePath="F:\\testPbToJson1,F:\\testPbToJson2,F:\\testPbToJson3";
        String [] filepaths=filePath.split(",");
        for (String filepath : filepaths) {
            File file=new File(filepath);
            File [] files=file.listFiles();
            int count=0;
            for (File file1 : files) {
                BufferedReader bufferedReader=new BufferedReader(new FileReader(file1));
                while (bufferedReader.ready()){
                    String line=bufferedReader.readLine();
                    if(line.trim().equals("")){
                        continue;
                    }
                    count++;
                }
                System.out.print(count);
                System.out.print(",");
            }
            System.out.println("目录:"+filepath+"有数据"+count+"");
        }
    }
}

 

posted @ 2016-12-14 16:04  life_start  阅读(177)  评论(0编辑  收藏  举报