Here you can find the source of toShortArray(final byte[] byteArray)
public static short[] toShortArray(final byte[] byteArray)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; import java.nio.ByteOrder; public class Main { public static short[] toShortArray(final byte[] byteArray) { short[] shortArray = new short[byteArray.length]; for (int i = 0; i < byteArray.length; i++) { shortArray[i] = toShort(byteArray[i]); }// w ww. ja va 2 s. co m return shortArray; } public static short toShort(final byte byteValue) { return toShort(byteValue, ByteOrder.LITTLE_ENDIAN); } public static short toShort(final byte byteValue, final ByteOrder byteOrder) { ByteBuffer byteBuffer = ByteBuffer.allocateDirect(2); byteBuffer.order(byteOrder); byteBuffer.put(byteValue); byteBuffer.put((byte) 0x00); byteBuffer.flip(); return byteBuffer.getShort(); } }