How to update a file ?

  • Thread starter Thread starter Andreas Palm
  • Start date Start date
A

Andreas Palm

I have the situation where I have a file in which there is one certain
line of text that I have to find and replace with another line of
text.
What is the simplest way to do this ?

best regards
andreas
 
Andreas Palm said:
I have the situation where I have a file in which there is one certain
line of text that I have to find and replace with another line of
text.
What is the simplest way to do this ?

There are two fairly simple solutions:

1) Read the whole file into memory, a line at a time. Modify the
appropriate line, then write the whole thing back. This clearly doesn't
scale well to large files.

2) Read the file a line at a time, writing it out to another file with
appropriate modifications.
 
Back
Top