Here you can find the source of byteToShort(byte[] b)
public static short byteToShort(byte[] b)
//package com.java2s; //License from project: Open Source License public class Main { public static short byteToShort(byte[] b) { short s = 0; short s0 = (short) (b[0] & 0xff); short s1 = (short) (b[1] & 0xff); s1 <<= 8;//from w ww . j a v a2 s . c om s = (short) (s0 | s1); return s; } }