Answers for "getting number of lines in text file in scanner in java"

2

get number of lines in a file java

BufferedReader reader = new BufferedReader(new FileReader("file.txt"));
int lines = 0;
while (reader.readLine() != null) lines++;
reader.close();
Posted by: Guest on September-02-2021
0

how to check the lines in a file java scanner

int count = 0;
while (scanner.hasNextLine()) {
    count++;
    scanner.nextLine();
}
Posted by: Guest on April-01-2020

Code answers related to "getting number of lines in text file in scanner in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language