Code example for RandomAccessFile

Methods: skipBytes, writeInt

0
            buffer[1] = (byte) ((size & 0x0000FF00) >> 8);
            buffer[2] = (byte) (size & 0x000000FF);
            file.write(buffer);
        } else { 
            // write the 4 byte size; 
            file.writeInt(size);
 
            // need to skip 2 flag bytes 
            file.skipBytes(2);
        } 
    } 
}