Example usage for java.nio FloatBuffer array

List of usage examples for java.nio FloatBuffer array

Introduction

In this page you can find the example usage for java.nio FloatBuffer array.

Prototype

public final float[] array() 

Source Link

Document

Returns the float array which this buffer is based on, if there is one.

Usage

From source file:Main.java

public static void main(String[] args) {
    FloatBuffer floatBuffer = FloatBuffer.allocate(10);
    floatBuffer.put(1.23F);//from  w ww.  j  av a 2  s  . com

    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(1, 1.23F);/*from   w w w .  j  a v a2 s.c o  m*/

    System.out.println(Arrays.toString(floatBuffer.array()));

}

From source file:Main.java

public static void main(String[] args) {
    FloatBuffer floatBuffer = FloatBuffer.wrap(new float[] { 1.23F });

    floatBuffer.rewind();//from  w  ww.  ja  va2s . c  om

    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:Main.java

public static void main(String[] args) {
    FloatBuffer floatBuffer = FloatBuffer.wrap(new float[] { 1.23F }, 0, 1);

    floatBuffer.rewind();/* w w w  . j  a  v a  2  s.  c o  m*/

    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, 2.13F, 3.13F, 2.13F, }, 0, 2);

    System.out.println(Arrays.toString(floatBuffer.array()));

}

From source file:Main.java

/**
 * Creates a float array from the provided {@link FloatBuffer}.
 * /*w w  w  .j a va2 s  .c o m*/
 * @param buffer {@link FloatBuffer} the data source.
 * @return float array containing the data of the buffer.
 */
public static float[] getFloatArrayFromBuffer(FloatBuffer buffer) {
    float[] array = null;
    if (buffer.hasArray()) {
        array = buffer.array();
    } else {
        buffer.rewind();
        array = new float[buffer.capacity()];
        buffer.get(array);
    }
    return array;
}