allocate Direct FloatBuffer - Java java.nio

Java examples for java.nio:FloatBuffer

Description

allocate Direct FloatBuffer

Demo Code


//package com.java2s;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import java.nio.FloatBuffer;

public class Main {
    public static void main(String[] argv) throws Exception {
        int size = 2;
        System.out.println(allocateDirectFloat(size));
    }/*from www  .j ava  2s  .co  m*/

    public static FloatBuffer allocateDirectFloat(int size) {
        ByteBuffer bb = ByteBuffer.allocateDirect(size * 4);
        bb.order(ByteOrder.nativeOrder());
        return bb.asFloatBuffer();
    }
}

Related Tutorials