publicstaticvoidl()throwsIOException{String p ="/Desktop/a/1.txt";LineNumberReader lineNumberReader =newLineNumberReader(newFileReader(p));//获取文件行数int lines =(int)Files.lines(Paths.get(p)).count();System.out.printf("文件共有 %s 行。\n",lines);//循环读取文件for(int i =0; i < lines; i++){System.out.println(lineNumberReader.readLine());}}