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