Here you can find the source of toShort(byte[] bytes, int index)
public static short toShort(byte[] bytes, int index)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; import java.nio.ByteOrder; public class Main { public static short toShort(byte[] bytes, int index) { return ByteBuffer.wrap(bytes, index, 2).order(ByteOrder.LITTLE_ENDIAN).getShort(); //return (short) ((0xff & bytes[index]) | (0xff & (bytes[index + 1] << 8))); }/*from w w w. j a v a 2 s .c o m*/ }