Here you can find the source of getSmart(ByteBuffer buf)
public static int getSmart(ByteBuffer buf)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static int getSmart(ByteBuffer buf) { int peek = buf.get(buf.position()) & 0xFF; if (peek < 128) { return buf.get() & 0xFF; } else {/*from ww w. j a v a 2s. c om*/ return (buf.getShort() & 0xFFFF) - 32768; } } }