Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    public static IntBuffer makeBuffer(int[] data) {
        ByteBuffer b = ByteBuffer.allocateDirect(data.length * 4);
        b.order(ByteOrder.nativeOrder());
        IntBuffer buffer = b.asIntBuffer();
        buffer.put(data);
        buffer.position(0);
        return buffer;
    }

    public static FloatBuffer makeBuffer(float[] data) {
        ByteBuffer b = ByteBuffer.allocateDirect(data.length * 4);
        b.order(ByteOrder.nativeOrder());
        FloatBuffer buffer = b.asFloatBuffer();
        buffer.put(data);
        buffer.position(0);
        return buffer;
    }
}