Cara Memeriksa Garis dalam File Java Scanner

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