Converting the (binary) bytes to
String data and back to bytes again assumes that the bytes represent text. If they don't, then changes may occur that damage the document (as in this case).
So don't use String or StringBuffer. Just read the bytes from one file and write them to the other file.
Personally I wouldn't use RandomAccessFiles for this task. I would use a BufferedInputStream to read into a buffer of something like 2048 bytes and a BufferedOutputStream to write that buffer into. Keep doing that (in a loop) until you have copied the entire file.