Manning's Countdown to 2014
. Use discount code crdotd14 all month for 50% off every deal.
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).
subject: How to get the total no. of Lines of a text file
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013