Here you can find the source of toShortArray(byte[] arr)
Parameter | Description |
---|---|
arr | Array of bytes |
public static short[] toShortArray(byte[] arr)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; import java.nio.ByteOrder; public class Main { /**/*w w w.ja va 2 s . c o m*/ * Convert byte array to short array * @param arr Array of bytes * @return Array of shorts */ public static short[] toShortArray(byte[] arr) { short[] shortBlocks = new short[arr.length / 2]; ByteBuffer.wrap(arr).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer().get(shortBlocks); return shortBlocks; } }