Here you can find the source of asShortBuffer(short[] array)
public static ShortBuffer asShortBuffer(short[] array)
//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 = Short.SIZE / Byte.SIZE; public static ShortBuffer asShortBuffer(short[] array) { ByteBuffer bbuf = ByteBuffer.allocateDirect(array.length * BYTES_PER_SHORT);/*ww w . jav a 2s . co m*/ bbuf.order(ByteOrder.nativeOrder()); ShortBuffer sbuf = bbuf.asShortBuffer(); sbuf.put(array); sbuf.position(0); return sbuf; } }