Code example for ByteBuffer

Methods: getShort

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