Stream for reading and deleting line

Hi All, I have to read a line from a text file and then delete that line from the file.which stream will be fit for it ? TIA

Jim Yingst

Wanderer
Sheriff

Posts: 18671

posted 14 years ago

There's really no single stream that can do this. What you'll probably have to do is read from one file and write to another. For each line that you read from the first file, after reading it you decide whether or not it should be copied to the new file, and then either write it there, or don't. After you're done reading everything, close both streams, delete the original file, and rename your new file to the name of the old file.