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

Recent Posts

  • Java Compact Source File: No Class, No Static Main
  • Java Scoped Values Example
  • Spring Boot RAG Example with Spring AI
  • Java AtomicInteger Example
  • Java Virtual Threads Example
  • Spring Boot Supabase CRUD Example
  • Spring Boot REST Docs Example
  • How to Install Java on Windows (Step-by-Step Guide)

© 2008–2026 mkyong.com

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