This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get the total no. of Lines of a text file

 
Mullin Yu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as subject!
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using the LineNumberReader class. Set it up something like this:

Then keep calling readLine() to read each line as a String, and getLineNumber() to determine which line you are on (note it starts counting at zero).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic