Here you can find the source of getUShort(ByteBuffer buffer)
public static int getUShort(ByteBuffer buffer)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static int getUShort(ByteBuffer buffer) { assert (buffer.capacity() - buffer.position() >= 2); byte[] data = new byte[2]; data[1] = buffer.get();//from w w w. j a va 2 s .co m data[0] = buffer.get(); return ((data[0] << 8) & 0x0000ff00) | (data[1] & 0x000000ff); } }