Java tutorial
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.ShortBuffer; public class Main { /** * Creates a {@link ShortBuffer} based on the given data. * * @param data the data for the buffer * @return the short buffer */ public static ShortBuffer createShortBuffer(final short[] data) { if (data == null) { return null; } ByteBuffer bbVertices = ByteBuffer.allocateDirect(data.length * 4); bbVertices.order(ByteOrder.nativeOrder()); final ShortBuffer fBuffer = bbVertices.asShortBuffer(); fBuffer.put(data); fBuffer.position(0); return fBuffer; } }