Skip to content

mkyong.com

  • Spring Boot
  • Java Virtual Threads
  • Contact
  1. Home /
  2. count line

Tag: count line

j
java June 1, 2010 4 min read by mkyong 10 comments

Java – Count number of lines in a file

This article shows few Java examples to get the total number of lines in a file. The steps are similar: Open the file. Read line by line, and increases count + 1 each line. Close the file. Read the count. Test Java Methods: Files.lines BufferedReader LineNumberReader BufferedInputStream At the end of the article, we also […]

Read more Java – Count number of lines in a file

Java and Spring tutorials since 2008. Every example is a complete, runnable file, compiled and run on a real machine before it goes out.

About This Site

  • About
  • Editorial Policy
  • Contact
  • Code License
  • Privacy Policy
  • Terms of Use

© 2026 mkyong.com — Powered by WordPress

RSS