Here you can find the source of unsignedShort(short s)
public static int unsignedShort(short s)
//package com.java2s; //License from project: Open Source License public class Main { public static int unsignedShort(short s) { byte[] array = shortToByteArray(s); int b1 = (0x000000FF & ((int) array[0])); int b2 = (0x000000FF & ((int) array[1])); return (b1 << 8 | b2); }//from w w w.j av a 2 s . c om public static byte[] shortToByteArray(short s) { return new byte[] { (byte) ((s & 0xFF00) >> 8), (byte) (s & 0x00FF) }; } }