Java ByteBuffer to Byte Array byteBufferToByteArray(ByteBuffer buf)

Here you can find the source of byteBufferToByteArray(ByteBuffer buf)

Description

byte Buffer To Byte Array

License

Apache License

Declaration

public static byte[] byteBufferToByteArray(ByteBuffer buf) 

Method Source Code

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

import java.nio.ByteBuffer;

public class Main {
    public static byte[] byteBufferToByteArray(ByteBuffer buf) {
        ByteBuffer str = buf.duplicate();
        //System.err.println("Before "+str);
        str.rewind();/*from  ww  w  .j  av  a 2s . c  o m*/
        //str.flip();
        //System.err.println("After "+str);
        byte[] dst = new byte[str.limit()];
        str.get(dst);
        return dst;
    }
}

Related

  1. asByteArray(ByteBuffer buf)
  2. asByteArray(ByteBuffer buf)
  3. ByteBufferToByteArray(ByteBuffer byteBuffer)
  4. byteBufferToByteArray(ByteBuffer byteBuffer)
  5. byteBufferToByteArray(List byteBufferList)
  6. byteBufferToBytes(ByteBuffer buffer)