List of usage examples for java.nio FloatBuffer put
public FloatBuffer put(FloatBuffer src)
From source file:Main.java
public static void main(String[] args) { FloatBuffer floatBuffer = FloatBuffer.allocate(10); floatBuffer.put(1.23F); System.out.println(Arrays.toString(floatBuffer.array())); }
From source file:Main.java
public static void main(String[] args) { FloatBuffer floatBuffer = FloatBuffer.allocate(10); floatBuffer.put(new float[] { 1.23F }); System.out.println(Arrays.toString(floatBuffer.array())); }
From source file:Buffers.java
public static void main(String[] args) { try {//from w w w . ja va2 s .c om float[] floats = { 6.61E-39F, 9.918385E-39F }; ByteBuffer bb = ByteBuffer.allocate(floats.length * 4); FloatBuffer fb = bb.asFloatBuffer(); fb.put(floats); CharBuffer cb = bb.asCharBuffer(); System.out.println(cb.toString()); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
From source file:Main.java
public static FloatBuffer makeFloatBufferFromArray(float[] arr) { ByteBuffer bb = ByteBuffer.allocateDirect(arr.length * 4); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(arr); fb.position(0);/*from w ww. jav a 2s . com*/ return fb; }
From source file:Main.java
/** * Make a direct NIO FloatBuffer from an array of floats * @param arr The array//from w w w.j ava 2s . c om * @return The newly created FloatBuffer */ public static FloatBuffer makeFloatBuffer(float[] arr) { ByteBuffer bb = ByteBuffer.allocateDirect(arr.length * 4); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(arr); fb.position(0); return fb; }
From source file:Main.java
public static FloatBuffer toFloatBuffer(float[] v) { ByteBuffer buff = ByteBuffer.allocateDirect(v.length * 4); buff.order(ByteOrder.nativeOrder()); FloatBuffer buffer = buff.asFloatBuffer(); buffer.put(v); buffer.position(0);//w w w .j a va2s .c o m return buffer; }
From source file:Main.java
public static FloatBuffer makeFloatBuffer(float[] i_arr) { ByteBuffer bb = ByteBuffer.allocateDirect(i_arr.length * 4); bb.order(ByteOrder.nativeOrder()); FloatBuffer fb = bb.asFloatBuffer(); fb.put(i_arr); fb.position(0);/*from ww w.j a va2 s. c om*/ return fb; }
From source file:Main.java
public static void addCoord2f(FloatBuffer buffer, float x, float y) { buffer.put(x); buffer.put(y);//w ww .j a v a2 s.c om }
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); buffer.put($b);/* w ww.jav a 2 s . c o m*/ buffer.put($c); buffer.position(0); return buffer; }
From source file:Main.java
/** * //w ww. j a va 2 s. c o m * @since 1.0.0 * @param v * @return the FloatBuffer */ public static FloatBuffer toFloatBuffer(float[] v) { ByteBuffer buf = ByteBuffer.allocateDirect(v.length * 4); buf.order(ByteOrder.nativeOrder()); FloatBuffer buffer = buf.asFloatBuffer(); buffer.put(v); buffer.position(0); return buffer; }