Java ByteBuffer to String toString(ByteBuffer buffer)

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

Description

to String

License

Apache License

Declaration

public static String toString(ByteBuffer buffer) throws UnsupportedEncodingException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;

public class Main {
    public static String toString(ByteBuffer buffer) throws UnsupportedEncodingException {
        byte[] bytes = new byte[buffer.remaining()];
        buffer.get(bytes);/*w w  w  .  j a  v a2s .c  om*/
        return new String(bytes, "utf-8");
    }
}

Related

  1. toString(ByteBuffer buffer)
  2. toString(ByteBuffer buffer)
  3. toString(ByteBuffer buffer)
  4. toString(ByteBuffer buffer)
  5. toString(ByteBuffer buffer)
  6. toString(ByteBuffer buffer)
  7. toString(ByteBuffer buffer, Charset charset)
  8. toString(ByteBuffer buffer, int offset, int length)
  9. toString(ByteBuffer buffer, String encoding)