Here you can find the source of toShort(byte[] in)
public static short toShort(byte[] in)
//package com.java2s; //License from project: LGPL public class Main { public static short toShort(byte[] in) { short out = 0; for (int i = in.length - 1; i > 0; i--) { out |= in[i] & 0xff;/*from w w w .j a v a2s .com*/ out <<= 8; } out |= in[0] & 0xff; return out; } }