Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
If the old string and new string are exactly the same length, you can update a file in place with RandomAccessFile. You can read the file until you find the starting position of the old string then start writing the bytes of the new string at that position. I probably would not take this approach because the next thing somebody asks you to change may not have old and new at exactly the same length.
I guess I'd recommend you read the file, make the changes and write it back out. You might read the whole file into memory so you can browse it beginning to end to look for related bits, or read one line, maybe change it, and write it out. Here's a strategy I've mentioned before:
This gives a lot of safety. You can fail in any step and still have uncorrupted file contents in some form.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
It looks like it's time for me to write you a reality check! Or maybe a tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss