Inserting text into textfiles

How would one insert a string into a text document...thanks


 
 
Last edited on
You have to rewrite the rest of the file after the point where you want to insert data.
is there a way to code this, or should it be
done manually...
You could read the rest of the file after the part you want to insert at into memory, then go back and rewrite the file (this may require a lot of memory), or, you can make a new file by taking the first part of the original file, the thing you want to insert, and then the rest of the original file (this doesn't require much memory at all but could also take a while).

If you know what I mean, you can also code it to decide which way to do it based on whether you insert late into the file or early into the file (or if the rest of the file would exceed memory).
Topic archived. No new replies allowed.