Example usage for java.nio ByteOrder nativeOrder

List of usage examples for java.nio ByteOrder nativeOrder

Introduction

In this page you can find the example usage for java.nio ByteOrder nativeOrder.

Prototype

public static ByteOrder nativeOrder() 

Source Link

Document

Returns the current platform byte order.

Usage

From source file:Main.java

public static ShortBuffer allocateShortBuffer(int capacity) {
    ByteBuffer vbb = ByteBuffer.allocateDirect(capacity);
    vbb.order(ByteOrder.nativeOrder());
    return vbb.asShortBuffer();
}

From source file:Main.java

public static ShortBuffer toShortBuffer(short[] values) {
    final ByteBuffer vbb = ByteBuffer.allocateDirect(values.length * 2);
    vbb.order(ByteOrder.nativeOrder());
    final ShortBuffer buffer = vbb.asShortBuffer();
    buffer.put(values);/* w w  w  .j a v a 2 s . co  m*/
    buffer.position(0);
    return buffer;
}

From source file:Main.java

public static ShortBuffer toShortBuffer(short[] values) {
    ByteBuffer vbb = ByteBuffer.allocateDirect(values.length * 2);
    vbb.order(ByteOrder.nativeOrder());
    ShortBuffer buffer = vbb.asShortBuffer();
    buffer.put(values);/*from  w w  w . j  a  va 2  s .  c  o m*/
    buffer.position(0);
    return buffer;
}

From source file:Main.java

public static FloatBuffer toFloatBufferPositionZero(float[] values) {
    final ByteBuffer vbb = ByteBuffer.allocateDirect(values.length * 4);
    vbb.order(ByteOrder.nativeOrder());
    final FloatBuffer buffer = vbb.asFloatBuffer();
    buffer.put(values);/* w  w w  .j a v a  2s . c  om*/
    buffer.position(0);
    return buffer;
}

From source file:Main.java

public static FloatBuffer toFloatBufferPositionZero(float[] values) {
    ByteBuffer vbb = ByteBuffer.allocateDirect(values.length * 4);
    vbb.order(ByteOrder.nativeOrder());
    FloatBuffer buffer = vbb.asFloatBuffer();
    buffer.put(values);//ww  w .j  a  v  a2s  .c o m
    buffer.position(0);
    return buffer;
}

From source file:Main.java

public static boolean isLittleEndian() {
    ByteOrder b = ByteOrder.nativeOrder();
    return b.equals(ByteOrder.LITTLE_ENDIAN);
}

From source file:Main.java

public static ByteBuffer createByteBufferOnHeap(final int size) {
    final ByteBuffer buf = ByteBuffer.allocate(size).order(ByteOrder.nativeOrder());
    buf.clear();//from   www  .j  a v  a  2  s.c  o m
    return buf;
}

From source file:Main.java

public static ShortBuffer transportArrayToNativeBuffer(short[] sArray) {
    ByteBuffer byteBuffer = ByteBuffer.allocateDirect(sArray.length * 2);
    byteBuffer.order(ByteOrder.nativeOrder());
    return (ShortBuffer) byteBuffer.asShortBuffer().put(sArray).position(0);
}

From source file:Main.java

public static IntBuffer createIntBufferOnHeap(final int size) {
    final IntBuffer buf = ByteBuffer.allocate(4 * size).order(ByteOrder.nativeOrder()).asIntBuffer();
    buf.clear();//from  www . j a v  a  2 s  .co m
    return buf;
}

From source file:Main.java

public static FloatBuffer createFloatBufferOnHeap(final int size) {
    final FloatBuffer buf = ByteBuffer.allocate(4 * size).order(ByteOrder.nativeOrder()).asFloatBuffer();
    buf.clear();//from  w  w  w . j  ava  2 s . co  m
    return buf;
}