Here you can find the source of readSize(ByteBuffer buf)
Parameter | Description |
---|---|
buf | Buffer |
public static int readSize(ByteBuffer buf)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { /**/*from w w w. j av a2 s . com*/ * Read size from ByteBuffer * @param buf Buffer * @return Size */ public static int readSize(ByteBuffer buf) { int s = 0; for (int count = 0; count < 4; count++) { byte b = (byte) (buf.get() & 0xff); s <<= 7; s |= b & 0x7f; if (0 == (b & 0x80)) { break; } } return s; } }