Here you can find the source of toShort(byte[] data)
public static short toShort(byte[] data)
//package com.java2s; public class Main { public static short toShort(byte[] data) { return byteArrayToShort(data, 0); }//from ww w.j a va2 s .co m 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; } return value; } }