Java ByteBuffer Create createByteBuffer(byte[] data)

Here you can find the source of createByteBuffer(byte[] data)

Description

Create a ByteBuffer for the provided data using the default byte order ( DataTypeTestUtil#DEFAULT_BYTE_ORDER ).

License

Apache License

Parameter

Parameter Description
data The data.

Return

The ByteBuffer for the data.

Declaration

public static ByteBuffer createByteBuffer(byte[] data) 

Method Source Code


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

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class Main {
    /** The default byte order. */
    public static final ByteOrder DEFAULT_BYTE_ORDER = ByteOrder.LITTLE_ENDIAN;

    /**/*w  w  w.j  a  v a2s. c  o  m*/
     * Create a ByteBuffer for the provided data using the default byte order ({@link DataTypeTestUtil#DEFAULT_BYTE_ORDER}).
     *
     * @param data The data.
     *
     * @return The ByteBuffer for the data.
     */
    public static ByteBuffer createByteBuffer(byte[] data) {
        return createByteBuffer(data, DEFAULT_BYTE_ORDER);
    }

    /**
     * Create a ByteBuffer for the provided data using the provided byte order.
     *
     * @param data      The data.
     * @param byteOrder The byte order.
     *
     * @return The ByteBuffer for the data.
     */
    public static ByteBuffer createByteBuffer(byte[] data, ByteOrder byteOrder) {
        return ByteBuffer.wrap(data).order(byteOrder);
    }
}

Related

  1. allocateByteBuffer(boolean useDirectBuffer, int bufSize)
  2. allocateByteBuffer(final int bytes)
  3. allocateByteBuffer(int capacity)
  4. createByteBuffer(byte... data)
  5. createByteBuffer(byte... values)
  6. createByteBuffer(int byteCount)
  7. createByteBuffer(int capacity)
  8. createByteBuffer(int capacity)
  9. createByteBuffer(int size)