Check out example codes for "how to check the lines in a file java scanner". It will help you in understanding the concepts better.

Code Example 1

int count = 0;
while (scanner.hasNextLine()) {
    count++;
    scanner.nextLine();
}

Learn ReactJs, React Native from akashmittal.com