Here you can find the source of decode(ByteBuffer bb)
public static String decode(ByteBuffer bb)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.charset.Charset; public class Main { private static Charset charset = Charset.forName("utf-8"); public static String decode(ByteBuffer bb) { return charset.decode(bb).toString(); }// ww w . j a va 2s . com public static String decode(byte[] bb) { try { return new String(bb, charset.displayName()); } catch (UnsupportedEncodingException e) { return ""; } } }