Java ByteBuffer Decode decode(ByteBuffer bb)

Here you can find the source of decode(ByteBuffer bb)

Description

decode

License

Open Source License

Declaration

public static String decode(ByteBuffer bb) 

Method Source Code


//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 "";
        }
    }
}

Related

  1. bytesToChars(CharsetDecoder decoder, ByteBuffer bytes, CharBuffer chars)
  2. decode(byte firstByte, ByteBuffer buffer, String charset)
  3. decode(ByteBuffer bb, CharsetDecoder decoder)
  4. decode(Charset charset, ByteBuffer buffer)
  5. decode(CharsetDecoder decoder, ByteBuffer src, CharBuffer dst)
  6. decode(String charsetName, ByteBuffer byteBuffer)