Java ByteBuffer to Byte Array byteBufferToBytes(ByteBuffer buffer)

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

Description

byte Buffer To Bytes

License

LGPL

Parameter

Parameter Description
buffer a parameter

Declaration

public static byte[] byteBufferToBytes(ByteBuffer buffer) 

Method Source Code

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

import java.nio.ByteBuffer;

import java.util.Arrays;

public class Main {
    /**//from w  w w  .jav a 2s .c o m
     * @param buffer
     * @return
     */
    public static byte[] byteBufferToBytes(ByteBuffer buffer) {
        final byte[] array = buffer.array();
        final int arrayOffset = buffer.arrayOffset();
        return Arrays.copyOfRange(array, arrayOffset + buffer.position(), arrayOffset + buffer.limit());
    }
}

Related

  1. asByteArray(ByteBuffer buf)
  2. byteBufferToByteArray(ByteBuffer buf)
  3. ByteBufferToByteArray(ByteBuffer byteBuffer)
  4. byteBufferToByteArray(ByteBuffer byteBuffer)
  5. byteBufferToByteArray(List byteBufferList)
  6. bytes(ByteBuffer bb)
  7. bytes(ByteBuffer buf)
  8. convertToBytes(@Nonnull ByteBuffer buffer)
  9. convertVarIntByteBufferToByteArray(ByteBuffer byteBuffer)