Delete a line

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How on earth do I read a lin from a text file, compare it to a string, and
the delte it if they are the same.

Thanx in advance
 
Vexander said:
How on earth do I read a lin from a text file, compare it to a
string, and the delte it if they are the same.

Hi Vexander,

one method is to read the text file into an arraylist, do all compare/delete
operations on this arraylist and afterwards write it back to the file.

Marco
 
Vexander said:
How on earth do I read a lin from a text file, compare it to a string, and
the delte it if they are the same.

Think of a file as data recorded on magnetic tape. VHS video is recorded on
magnetic tape, and what you want to do is like watching a program and deleting
all the commercials. You can't just delete them because you'd leave blank
spaces where the commercials were. You either have to physically cut and
splice the tape, or record it to a new tape, without the comercials....

The data on a disk is just like that, each piece of data has a physical location.
You can't expect them to move if you try to delete one, you can only over-
write it with something else. Since you can't cut and splice a disk, your only
option is to copy the data to a new file, minus all the stuff you want to delete.

LFS
 
Think of a file as data recorded on magnetic tape. VHS video is recorded on
LFS

Hi Larry,

I have seen this question asked many times on these groups and I must say
that your magnetic tape analogies, so far, is the best explanation I have
seen.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top