Here you can find the source of bytesToShort(byte A, byte B)
public static short bytesToShort(byte A, byte B)
//package com.java2s; //License from project: Open Source License public class Main { public static final short MASK_TO_BYTE = 0xFF; public static short bytesToShort(byte A, byte B) { short i = (short) (B & MASK_TO_BYTE); i |= ((A & MASK_TO_BYTE) << 8); return i; }//from w w w. j a v a 2 s. com }