Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.nio.FloatBuffer;

public class Main {
    /**
     * Creates a float array from the provided {@link FloatBuffer}.
     * 
     * @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;
    }
}