This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Number of lines in the text file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Number of lines in the text file" Watch "Number of lines in the text file" New topic
Author

Number of lines in the text file

Mike Yu
Ranch Hand

Joined: Nov 17, 2001
Posts: 175
Hi,

What is the easiest way to find the total number of lines in a text file?
I know we can create a LineNumberReader and count it line by line.

Thnaks,
Mike


Thanks,<br />Mike
Petrus Pelser
Ranch Hand

Joined: Feb 20, 2006
Posts: 132
I don't think that the number of lines in a text file is stated explicitly (like for example the file's size). You would have to calculate it manually. Yes that means counting them one by one.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Number of lines in the text file
 
Similar Threads
How to replace data in a file
generate a text file with random no of characters
using linereader
text file ?? simple program
read specific line from text file