Here you can find the source of readSmart(ByteBuffer buffer)
Parameter | Description |
---|---|
buffer | The buffer. |
public static int readSmart(ByteBuffer buffer)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { /**//from ww w . j av a 2 s .com * Reads a 'smart' (either a {@code byte} or {@code short} depending on the value) from the specified buffer. * * @param buffer The buffer. * @return The 'smart'. */ public static int readSmart(ByteBuffer buffer) { int peek = buffer.get(buffer.position()) & 0xFF; if (peek < 128) { return buffer.get() & 0xFF; } return (buffer.getShort() & 0xFFFF) - 32768; } }