Java ByteBuffer to String byteBufferToString(ByteBuffer buffer)

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

Description

byte Buffer To String

License

Open Source License

Declaration

public static String byteBufferToString(ByteBuffer buffer) 

Method Source Code

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

import java.nio.ByteBuffer;

public class Main {
    public static String byteBufferToString(ByteBuffer buffer) {
        StringBuffer sb = new StringBuffer("[");

        if (buffer.hasRemaining())
            sb.append(buffer.get());/*from   w ww  . j a v a  2  s .  c  o  m*/
        while (buffer.hasRemaining())
            sb.append(", ").append(buffer.get());
        sb.append("]");

        buffer.rewind();

        return new String(sb);
    }
}

Related

  1. bufferToString(ByteBuffer buf)
  2. bufferToString(ByteBuffer buf)
  3. bufferToString(ByteBuffer buff)
  4. bufferToString(ByteBuffer buffer)
  5. byteBufferToString(ByteBuffer buf)
  6. byteBufferToString(ByteBuffer buffer)
  7. byteBufferToString(ByteBuffer buffer)
  8. byteBufferToString(ByteBuffer buffer)
  9. byteBufferToString(ByteBuffer buffer)