Pad the original entry with enough space that RandomAccessFile can be used (and you don't care about some extra trailing space. Easy, but limited utility
Use a templating engine (StringTemplate, Velocity, etc) if you are doing this a lot. Possibly too much work if you are doing this just once.
Write your own simple templating engine that reads it into memory does a regex replacement and writes it back. Not especially efficient but if you have very simple and limited usage, maybe the best compromise.