List of usage examples for java.nio ByteBuffer order
Endianness order
To view the source code for java.nio ByteBuffer order.
Click Source Link
From source file:Main.java
public static FloatBuffer makeBuffer(float[] data) { ByteBuffer b = ByteBuffer.allocateDirect(data.length * 4); b.order(ByteOrder.nativeOrder()); FloatBuffer buffer = b.asFloatBuffer(); buffer.put(data);//from w w w. j a va2 s . co m buffer.position(0); return buffer; }
From source file:Main.java
public static long Uint64FromBuffer(byte[] buffer, int offset) { ByteBuffer bb = ByteBuffer.wrap(buffer, offset, 8); bb.order(ByteOrder.BIG_ENDIAN); long result = bb.getLong(); return result; }
From source file:Main.java
public static ByteBuffer makeByteBuffer(byte[] array) { if (array == null) throw new IllegalArgumentException(); ByteBuffer byteBuffer = ByteBuffer.allocateDirect(array.length); byteBuffer.order(ByteOrder.nativeOrder()); byteBuffer.put(array);/* w ww . j a va 2 s .co m*/ byteBuffer.position(0); return byteBuffer; }
From source file:Main.java
public static FloatBuffer makeFloatBuffer3(float $a, float $b, float $c) { ByteBuffer b = ByteBuffer.allocateDirect(3 * BYTES_PER_FLOAT); b.order(ByteOrder.nativeOrder()); FloatBuffer buffer = b.asFloatBuffer(); buffer.put($a);/*ww w . j av a2s . com*/ buffer.put($b); buffer.put($c); buffer.position(0); return buffer; }
From source file:Main.java
public static CharBuffer newCharBuffer(int numChars) { ByteBuffer buffer = ByteBuffer.allocateDirect(numChars * 2); buffer.order(ByteOrder.nativeOrder()); return buffer.asCharBuffer(); }
From source file:Main.java
public static IntBuffer createIndexBuffer(int[] indices) { IntBuffer indexBuffer;// w w w . j av a2 s . c o m ByteBuffer bb = ByteBuffer.allocateDirect(indices.length * 4); bb.order(ByteOrder.nativeOrder()); indexBuffer = bb.asIntBuffer(); indexBuffer.put(indices); indexBuffer.position(0); return indexBuffer; }
From source file:Main.java
public static IntBuffer newIntBuffer(int numInts) { ByteBuffer buffer = ByteBuffer.allocateDirect(numInts * 4); buffer.order(ByteOrder.nativeOrder()); return buffer.asIntBuffer(); }
From source file:Main.java
public static FloatBuffer allocateFloatBuffer(int capacity) { final ByteBuffer vbb = ByteBuffer.allocateDirect(capacity); vbb.order(ByteOrder.nativeOrder()); return vbb.asFloatBuffer(); }
From source file:Main.java
public static LongBuffer newLongBuffer(int numLongs) { ByteBuffer buffer = ByteBuffer.allocateDirect(numLongs * 8); buffer.order(ByteOrder.nativeOrder()); return buffer.asLongBuffer(); }
From source file:Main.java
public static ShortBuffer allocateShortBuffer(int capacity) { final ByteBuffer vbb = ByteBuffer.allocateDirect(capacity); vbb.order(ByteOrder.nativeOrder()); return vbb.asShortBuffer(); }