Here you can find the source of toShort(byte[] bytes, int from)
public static short toShort(byte[] bytes, int from)
//package com.java2s; public class Main { public static short toShort(byte[] bytes, int from) { short result = 0; for (int i = 0; i < 2; i++) { short b = (short) (((int) bytes[from + i]) & 0xFF); result = (short) ((result << 8) | b); }/* w ww . jav a 2 s . c o m*/ return result; } }