Use the RandomAccessFile class.