get number of lines in a file java

Solutions on MaxInterview for get number of lines in a file java by the best coders in the world

showing results for - "get number of lines in a file java"
Orianna
13 Oct 2019
1BufferedReader reader = new BufferedReader(new FileReader("file.txt"));
2int lines = 0;
3while (reader.readLine() != null) lines++;
4reader.close();
5