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