File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
How to get the total no. of Lines of a text file
Joined: Feb 24, 2005
Jun 12, 2005 10:32:00
Joined: Apr 21, 2005
Jun 12, 2005 11:31:00
Try using the
class. Set it up something like this:
FileInputStream fin = new FileInputStream("foo.dat"); LineNumberReader lnr = new LineNumberReader(new InputStreamReader(fin));
Then keep calling readLine() to read each line as a
, and getLineNumber() to determine which line you are on (note it starts counting at zero).
I agree. Here's the link:
subject: How to get the total no. of Lines of a text file
StringTokenizer and End of file question
Simple Text based Email : Problem with Russian Characters
assign faculty members to classes
How to iterate through an Array of objects and a file at the same time?
include contents of an .inc file as in HTML pages
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015