Here you can find the source of bytesToShort(byte[] b)
public static short bytesToShort(byte[] b)
//package com.java2s; public class Main { public static short bytesToShort(byte[] b) { short s0 = (short) (b[0] & 0xff); short s1 = (short) (b[1] & 0xff); s1 <<= 8;//from ww w. ja v a 2s .co m return (short) (s0 | s1); } }