Here you can find the source of byteArrayToShort(byte[] b, int offset)
private static short byteArrayToShort(byte[] b, int offset)
//package com.java2s; public class Main { private static short byteArrayToShort(byte[] b, int offset) { short value = 0; for (int i = 0; i < 2; i++) { int shift = (2 - 1 - i) * 8; value += (b[i + offset] & 0x000000FF) << shift; }/* w w w .j a va 2 s .com*/ return value; } }