Here you can find the source of decode(byte firstByte, ByteBuffer buffer, String charset)
public static final String decode(byte firstByte, ByteBuffer buffer, String charset)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; public class Main { private static final long OB_MAX_1B_STR_LEN = 55; private static final byte OB_VARCHAR_LEN_MASK = 0x3f; public static final String decode(byte firstByte, ByteBuffer buffer, String charset) {/*from w w w. ja va 2 s .c o m*/ int lenOrValue = firstByte & OB_VARCHAR_LEN_MASK; int strLen = 0; if (lenOrValue <= OB_MAX_1B_STR_LEN) { strLen = lenOrValue; } else { for (int n = 0; n < lenOrValue - OB_MAX_1B_STR_LEN; n++) { strLen |= ((buffer.get() & 0xffl) << (n << 3)); } } byte[] ret = new byte[strLen]; buffer.get(ret); try { return new String(ret, charset); } catch (UnsupportedEncodingException e) { return "";// never happen } } }