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.ShortBuffer;

public class Main {
    public static ShortBuffer createShortBuffer(short[] shortData) {
        ShortBuffer drawListBuffer;
        ByteBuffer dlb = ByteBuffer.allocateDirect(
                // (# of coordinate values * 2 bytes per short)
                shortData.length * 2);
        dlb.order(ByteOrder.nativeOrder());
        drawListBuffer = dlb.asShortBuffer();
        drawListBuffer.put(shortData);
        drawListBuffer.position(0);
        return drawListBuffer;
    }
}