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) { if (data == null || data.length != 2) return 0x0; // ---------- return (short) ((0xff & data[0]) << 8 | (0xff & data[1]) << 0); }/*from ww w .j a va 2 s . c o m*/ }