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.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;

public class Main {
    public static ByteBuffer create(int size) {
        return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
    }

    public static FloatBuffer create(float[] data) {
        FloatBuffer fb = create(data.length * 4).asFloatBuffer().put(data);
        fb.position(0);
        return fb;
    }

    public static ShortBuffer create(short[] data) {
        ShortBuffer sb = create(data.length * 2).asShortBuffer().put(data);
        sb.position(0);
        return sb;
    }
}