create FloatBuffer by size - Android java.nio

Android examples for java.nio:FloatBuffer

Description

create FloatBuffer by size

Demo Code


import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;

public class Main{
    public static final FloatBuffer createFloatBuffer(int size) {
        return ByteBuffer
                .allocateDirect(size * DatatypeUtils.FLOAT_SIZE_BYTES)
                .order(ByteOrder.nativeOrder()).asFloatBuffer();
    }//from  www  .ja  va  2  s.c o m
}

Related Tutorials