Could anyone help me with an efficient(and easy) way to insert data in a file directly(with out using temp file).
example
open the file1.txt
11112222
333333
44444444
and insert something say " 99999 " somewhere inside the file
as
11112222
333 99999 333
44444444
If the file is relatively small you can read the entire file into memory and just write it out, inserting the new text at the appropriate place, using the original file name.
...and if it isn't, you still can't just insert data, you have to update the entire file after the point of insertion.