Java tutorial
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.ShortBuffer; public class Main { public static ShortBuffer toShortBuffer(short[] v) { ByteBuffer buff = ByteBuffer.allocateDirect(v.length * 2); buff.order(ByteOrder.nativeOrder()); ShortBuffer buffer = buff.asShortBuffer(); buffer.put(v); buffer.position(0); return buffer; } }