Code example for ByteBuffer

Methods: putShort

     * @param bb ByteBuffer to put the short into 
     * @param v the int containing the unsigned short 
     * @param offset the offset to insert the unsigned short at 
    public static void putUnsignedShort(ByteBuffer bb, int v, int offset) {
        bb.putShort(offset, (short) (v & 0xffff));
     * Get an unsigned int from the current position of the ByteBuffer 
     * @param bb ByteBuffer to get the int from 
     * @return an unsigned int contained in a long 
    public static long getUnsignedInt(ByteBuffer bb) {
        return ((long) bb.getInt() & 0xffffffffL);
     * Get an unsigned int from the specified offset in the ByteBuffer