Path path = Paths.get(fileName); long lines = 0; lines = Files.lines(path).count(); System.out.println(lines);