You could also use a RandomAccessFile, calling seek to move to a particular position to write.