Here you can find the source of buildShortBuffer(short[] buffer)
Parameter | Description |
---|---|
buffer | a parameter |
public static ShortBuffer buildShortBuffer(short[] buffer)
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.ShortBuffer; public class Main { /**/*from w w w.ja v a2 s. co m*/ * build ShortBuffer: short[] -> ShortBuffer * * @param buffer * @return ShortBuffer */ public static ShortBuffer buildShortBuffer(short[] buffer) { ShortBuffer ret = null; if (buffer != null) { ByteBuffer byteBuffer = ByteBuffer .allocateDirect(buffer.length * 2); byteBuffer.order(ByteOrder.nativeOrder()); ret = byteBuffer.asShortBuffer(); ret.put(buffer); ret.position(0); } return ret; } }