Here you can find the source of makeShortBuffer(short[] arr)
public static ShortBuffer makeShortBuffer(short[] arr)
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.ShortBuffer; public class Main { public static ShortBuffer makeShortBuffer(short[] arr) { ByteBuffer bb = ByteBuffer.allocateDirect(arr.length * 2); bb.order(ByteOrder.nativeOrder()); ShortBuffer Ib = bb.asShortBuffer(); Ib.put(arr);/*from w ww. j a v a 2 s . c o m*/ Ib.position(0); return Ib; } public static ShortBuffer makeShortBuffer(int size) { ByteBuffer bb = ByteBuffer.allocateDirect(size * 2); bb.order(ByteOrder.nativeOrder()); ShortBuffer Ib = bb.asShortBuffer(); Ib.position(0); return Ib; } }