Java ByteBuffer Extract extract(ByteBuffer buf)

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

Description

Properly extract the byte contents of a ByteBuffer

License

Open Source License

Parameter

Parameter Description
buf The buffer whose content is to be extracted as defined by the buffer limit.

Return

The byte array contents of the buffer

Declaration

static public byte[] extract(ByteBuffer buf) 

Method Source Code

//package com.java2s;
/* Copyright 2012, UCAR/Unidata.
 See the LICENSE file for more information. */

import java.nio.ByteBuffer;

public class Main {
    /**/*from  w  w  w . ja v  a2  s .  c  o m*/
     * Properly extract the byte contents of a ByteBuffer
     *
     * @param buf The buffer whose content is to be extracted
     *            as defined by the buffer limit.
     * @return The byte array contents of the buffer
     */
    static public byte[] extract(ByteBuffer buf) {
        int len = buf.limit();
        byte[] bytes = new byte[len];
        buf.rewind();
        buf.get(bytes);
        return bytes;
    }
}

Related

  1. extractBytes(ByteBuffer buf)
  2. extractBytes(ByteBuffer buffer, int size)
  3. extractBytes(ByteBuffer byteBuffer, byte startByte, byte endByte)
  4. extractSingleHighCardDims(byte[] highCardArr, int index, int highCardinalityCount, ByteBuffer outBuffer)