Here you can find the source of createShortBuffer(short[] shortData)
public static final ShortBuffer createShortBuffer(short[] shortData)
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.ShortBuffer; public class Main { public static final int BYTES_PER_SHORT = 2; public static final ShortBuffer createShortBuffer(short[] shortData) { ShortBuffer buffer = ByteBuffer .allocateDirect(shortData.length * BYTES_PER_SHORT) .order(ByteOrder.nativeOrder()).asShortBuffer() .put(shortData);/*from ww w.java2 s. c o m*/ buffer.position(0); return buffer; } }