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.