I need to replace a word by another without using `replace` and `replaceAll` functions in a text.

If the word I want to replace has the same length as the original one there aren't any problems. The problem is when the word I want to replace is longer or shorter than the original.

For example: I want to replace "one" by "thirteen" in the string "I have one dog". This is what I tried to do (I use `RandomAccessFile` class):

```
RandomAccessFile r  = new RandomAccessFile("toto.txt","rw")
r.seek(position); // imagine that position is the right cursor which take place under the o from the word "one"
r.writeBytes("thirteen");

```

When I try this I erase the words after dog because "thirteen" is longer than "one"..

Same problem if the word I want to replace is shorter than the original. I replaced the remaining letters by blank letters but I have ugly blank spaces...

How can I proceed?