Java ByteBuffer from getByteBuffer(int size)

Here you can find the source of getByteBuffer(int size)

Description

Returns a fully initialized empty ByteBuffer in little endian order.

License

Open Source License

Declaration

public static ByteBuffer getByteBuffer(int size) 

Method Source Code

//package com.java2s;
// See LICENSE.txt for license information

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

public class Main {
    /** Returns a fully initialized empty {@link ByteBuffer} in little endian order. */
    public static ByteBuffer getByteBuffer(int size) {
        return ByteBuffer.allocate(Math.max(0, size)).order(ByteOrder.LITTLE_ENDIAN);
    }//from w  ww  .  j av  a2 s . co  m

    /** Returns a {@link ByteBuffer} based on {@code buffer} in little endian order. */
    public static ByteBuffer getByteBuffer(byte[] buffer) {
        if (buffer == null) {
            buffer = new byte[0];
        }
        return ByteBuffer.wrap(buffer).order(ByteOrder.LITTLE_ENDIAN);
    }
}

Related

  1. getByteBuffer(byte[] array)
  2. getByteBuffer(byte[] data, int fromByte, int length)
  3. getByteBuffer(ByteBuffer source, int count)
  4. getByteBuffer(final String string, final Charset charset)
  5. getByteBuffer(Object obj)
  6. getByteBuffer(String base64)
  7. getByteBuffer(String filePath, int start, long size)
  8. getByteBufferArray(ByteBuffer byteBuffer)