Java ByteBuffer to String byteBufferToString(ByteBuffer stringBuf)

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

Description

byte Buffer To String

License

Open Source License

Declaration

private static String byteBufferToString(ByteBuffer stringBuf) 

Method Source Code

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

import java.nio.ByteBuffer;

public class Main {
    private static String byteBufferToString(ByteBuffer stringBuf) {
        /* The (- 1) is to remove the \0 character */
        byte[] bytes = new byte[stringBuf.remaining() - 1];
        stringBuf.get(bytes);/*from   ww w  .  jav a2 s. c om*/
        return new String(bytes);
    }
}

Related

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