Here you can find the source of toShort(byte[] b, int off, boolean bigEndian)
public static short toShort(byte[] b, int off, boolean bigEndian)
//package com.java2s; //License from project: Open Source License public class Main { public static short toShort(byte[] b, int off, boolean bigEndian) { if (bigEndian) { return (short) (((b[0] & 0xff) << 8) | (b[1] & 0xff)); } else {//from www . ja v a 2s . com return (short) (((b[1] & 0xff) << 8) | (b[0] & 0xff)); } } public static void toShort(short[] s, int sOff, byte[] b, int bOff, int bLen, boolean bigEndian) { int bEnd = bOff + bLen; for (int j = bOff, k = sOff; j < bEnd; j += 2, k++) { s[k] = toShort(b, j, bigEndian); } } }