This code gives a snippet showing conversion of byte array into short, int and long datatype
//This method converts byte array into short public static short getShort(byte[] array, int offset) { return ((array[offset] & 0xff) << 8) | (array[offset+1] & 0xff); } //This method converts byte array into itn public static int getInt(byte[] array, int offset) { return ((array[offset] & 0xff) << 24) | ((array[offset+1] & 0xff) << 16) | ((array[offset+2] & 0xff) << 8) | (array[offset+3] & 0xff); } //This method converts byte array into long public static long getLong(byte[] array, int offset) { return ((long)(array[offset] & 0xff) << 56) | ((long)(array[offset+1] & 0xff) << 48) | ((long)(array[offset+2] & 0xff) << 40) | ((long)(array[offset+3] & 0xff) << 32) | ((long)(array[offset+4] & 0xff) << 24) | ((long)(array[offset+5] & 0xff) << 16) | ((long)(array[offset+6] & 0xff) << 8) | ((long)(array[offset+7] & 0xff)); }