Java ByteBuffer to String convertBufferToString(ByteBuffer buffer)

Here you can find the source of convertBufferToString(ByteBuffer buffer)

Description

convert Buffer To String

License

Open Source License

Declaration

public static String convertBufferToString(ByteBuffer buffer) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.nio.ByteBuffer;

public class Main {
    public static String convertBufferToString(ByteBuffer buffer) {
        if (buffer.remaining() == 0)
            return "";
        byte[] bytes = new byte[buffer.limit()];
        buffer.get(bytes);//w ww. j  av  a 2 s.  c o m
        return new String(bytes);
    }
}

Related

  1. byteBufferToString(ByteBuffer buffer)
  2. ByteBufferToString(ByteBuffer buffer, Charset charset)
  3. byteBufferToString(ByteBuffer buffer, String encoding)
  4. byteBufferToString(ByteBuffer stringBuf)
  5. bytesToString(ByteBuffer buf, int off, int len)
  6. decodeString(ByteBuffer bb)
  7. decodeString(ByteBuffer buffer, String charset)
  8. decodeString(ByteBuffer src)
  9. getStr(ByteBuffer buff)