Java ByteBuffer Create createByteBuffer(byte... values)

Here you can find the source of createByteBuffer(byte... values)

Description

Constructs a direct native-ordered bytebuffer with the specified size.

License

Open Source License

Parameter

Parameter Description
values the values

Return

a ByteBuffer

Declaration

public static ByteBuffer createByteBuffer(byte... values) 

Method Source Code


//package com.java2s;

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

public class Main {
    /**//  w ww. j ava2  s.  c o  m
     * Constructs a direct native-ordered bytebuffer with the specified size.
     * 
     * @param size The size, in bytes
     * 
     * @return a ByteBuffer
     */
    public static ByteBuffer createByteBuffer(int size) {
        return (ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder()));
    }

    /**
     * Constructs a direct native-ordered bytebuffer with the specified size.
     * 
     * @param values the values
     * 
     * @return a ByteBuffer
     */
    public static ByteBuffer createByteBuffer(byte... values) {
        ByteBuffer buff = createByteBuffer(values.length);
        buff.flip();

        return (buff);
    }
}

Related

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