Java ByteBuffer to Byte Array getBytes(ByteBuffer buf, byte[] arr)

Here you can find the source of getBytes(ByteBuffer buf, byte[] arr)

Description

Retrieves arr.length bytes from ByteBuffer

License

Open Source License

Parameter

Parameter Description
buf a parameter
arr a parameter

Return

whether the BB.get() operation was successful or not

Declaration

public static boolean getBytes(ByteBuffer buf, byte[] arr) 

Method Source Code


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

import java.nio.ByteBuffer;

public class Main {
    /**/*  w ww  .  java 2  s  .c o m*/
     * Retrieves arr.length bytes from ByteBuffer
     * @param buf
     * @param arr
     * @return whether the BB.get() operation was successful or not
     */
    public static boolean getBytes(ByteBuffer buf, byte[] arr) {
        if (buf.remaining() < arr.length)
            return false;
        buf.get(arr);
        return true;
    }
}

Related

  1. getByteArrayFromBuffer(ByteBuffer byteBuf)
  2. getByteArrayFromByteBuffer(ByteBuffer content)
  3. getBytes(ByteBuffer bb)
  4. getBytes(ByteBuffer buf)
  5. getBytes(ByteBuffer buf)
  6. getBytes(ByteBuffer buf, int length)
  7. getBytes(ByteBuffer buffer, int len)
  8. getBytes(ByteBuffer byteBuffer, int length)
  9. getBytes(ByteBuffer bytes)