Java tutorial
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.ShortBuffer; public class Main { public static ShortBuffer shortToBuffer(short[] a) { ShortBuffer shortBuffer; ByteBuffer ibb = ByteBuffer.allocateDirect(a.length * 2); ibb.order(ByteOrder.nativeOrder()); shortBuffer = ibb.asShortBuffer(); shortBuffer.put(a); shortBuffer.position(0); return shortBuffer; } }