Java examples for java.nio:ShortBuffer
make ShortBuffer
//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 a v a 2 s .com 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; } }