Java ByteBuffer Decode decodeBuffer(ByteBuffer buffer, String charsetName)

Here you can find the source of decodeBuffer(ByteBuffer buffer, String charsetName)

Description

decode Buffer

License

Open Source License

Declaration

protected static String decodeBuffer(ByteBuffer buffer,
            String charsetName) 

Method Source Code

//package com.java2s;
import java.io.*;

import java.nio.*;

public class Main {
    protected static String decodeBuffer(ByteBuffer buffer,
            String charsetName) {
        byte[] bytes = new byte[buffer.limit()];
        buffer.get(bytes);/*from   ww  w .j a va2  s  . c  o m*/
        try {
            return new String(bytes, charsetName);
        } catch (UnsupportedEncodingException e) {
            return new String(bytes);
        }
    }
}

Related

  1. decode(Charset charset, ByteBuffer buffer)
  2. decode(CharsetDecoder decoder, ByteBuffer src, CharBuffer dst)
  3. decode(String charsetName, ByteBuffer byteBuffer)
  4. decodeAlign(ByteBuffer buf)
  5. decodeASCII(ByteBuffer buffer, int length, int offset)
  6. decodeDouble(ByteBuffer bb)
  7. decodeInt(ByteBuffer buffer, int start)
  8. decodeIO(String encoding, ByteBuffer bbuf)
  9. decodeLength(ByteBuffer buf)