Here you can find the source of byte2short(byte[] ba)
public static short[] byte2short(byte[] ba)
//package com.java2s; //License from project: Open Source License public class Main { public static short[] byte2short(byte[] ba) { int length = ba.length; short[] sa = new short[length / 2]; for (int i = 0, j = 0; j < length / 2;) { sa[j++] = (short) (((ba[i++] & 0xFF) << 8) | ((ba[i++] & 0xFF))); }// www .j av a 2 s .com return (sa); } }