Here you can find the source of toShort(byte... b)
public static short toShort(byte... b)
//package com.java2s; /**// w w w. ja v a 2 s .co m * License * * Licensed under the GNU GPL v3 * http://www.gnu.org/licenses/gpl.html * */ public class Main { public static short toShort(byte... b) { return (short) toLong(b); } public static long toLong(byte... b) { long l = 0; int len = b.length; for (int i = 0; i < len && i < 8; i++) { l = (long) l << 8 | byte2UnsignInt(b[i]); } return l; } public static int byte2UnsignInt(byte b) { if (b >> 1 == b >>> 1) return b; else return 256 + b; } }