new Float Buffer - Java java.nio

Java examples for java.nio:FloatBuffer

Description

new Float Buffer

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 paramInt = 2;
        System.out.println(newFloatBuffer(paramInt));
    }//w  w w . j  a  v a2  s . c o m

    public static FloatBuffer newFloatBuffer(int paramInt) {
        ByteBuffer localByteBuffer = newByteBuffer(paramInt * 4);
        return localByteBuffer.asFloatBuffer();
    }

    public static ByteBuffer newByteBuffer(int paramInt) {
        ByteBuffer localByteBuffer = ByteBuffer.allocateDirect(paramInt);
        localByteBuffer.order(ByteOrder.nativeOrder());
        return localByteBuffer;
    }
}

Related Tutorials