A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
this week in the
lines problem in a file.txt
Joined: Oct 21, 2012
Nov 17, 2012 18:32:50
i am having difficulties to write a code that will tell me the amount of lines within 2 files.
I am using nextline() to detect the lines from the 2 files, but when i want to go back to the top of the file and edit something, it wont allow me since i am already at the bottom of the text file.
How would i get around this problem, to check the lines, if its the same on both files?
Joined: Jan 03, 2004
Nov 17, 2012 18:35:35
If you want to know how many lines are in a file, you read that file, a line at a time, and keep a count as you go.
If you want to edit the file, you read the file in, change the lines you want to change, and write the file back out.
You can do both at the same time if the editing doesn't depend on the number of lines. If it does depend on it, then you'll have to make two passes.
I agree. Here's the link:
subject: lines problem in a file.txt
Alternatives to arrays
File splitting with Java..Help
pdf to text conversion using java library
How to divide File in Java
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014