Here you can find the source of makeShortBuffer(int size)
public static ShortBuffer makeShortBuffer(int size)
//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);/*w ww .j av a2 s . co 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; } }