Java ByteBuffer from getByteBufferAsString(ByteBuffer buff)

Here you can find the source of getByteBufferAsString(ByteBuffer buff)

Description

get Byte Buffer As String

License

Open Source License

Declaration

public static String getByteBufferAsString(ByteBuffer buff) 

Method Source Code


//package com.java2s;
/*//from  w  w  w  .ja v a 2 s . c om
 * Copyright (C) Mellanox Technologies Ltd. 2001-2017.  ALL RIGHTS RESERVED.
 * See file LICENSE for terms.
 */

import java.nio.ByteBuffer;
import java.nio.charset.Charset;

public class Main {
    public static String getByteBufferAsString(ByteBuffer buff) {
        int pos = buff.position();
        byte[] tmpBuff = new byte[buff.remaining()];
        buff.get(tmpBuff);
        buff.position(pos);
        return new String(tmpBuff, Charset.forName("US-ASCII"));
    }
}

Related

  1. getByteBuffer(int size)
  2. getByteBuffer(Object obj)
  3. getByteBuffer(String base64)
  4. getByteBuffer(String filePath, int start, long size)
  5. getByteBufferArray(ByteBuffer byteBuffer)
  6. getByteBufferByString(String message)
  7. getByteBufferFromBytes(byte[] data)
  8. getByteBufferFromInt(int value)
  9. getByteBufferFromList(List values)

    HOME | Copyright © www.java2s.com 2016