Android Byte Array Bit Get getByteNetOrderTo_unit16(byte[] theBytes, int idx)

Here you can find the source of getByteNetOrderTo_unit16(byte[] theBytes, int idx)

Description

pull out unsigned 16 bits integer out of the array.

Parameter

Parameter Description
theBytes - the array
idx - the starting index

Return

the num (0-65535)

Declaration

public static int getByteNetOrderTo_unit16(byte[] theBytes, int idx) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*  w ww. j  a v a  2s .  co m*/
     * pull out unsigned 16 bits integer out of the array.
     * @param theBytes - the array
     * @param idx - the starting index
     * @return the num (0-65535)
     */
    public static int getByteNetOrderTo_unit16(byte[] theBytes, int idx) {
        int sum = 0;
        for (int i = 0; i < 2; i++) {
            sum = (sum << 8) + (0xff & theBytes[i + idx]);
        }
        return sum;
    }
}

Related

  1. getBitData(byte[] src, int index)
  2. getBitData(byte[] src, int index, boolean isLH)
  3. getBitData(byte[] src, int start, int end)
  4. getBitData(byte[] src, int start, int end, boolean isLH)
  5. getByteNetOrder(byte[] theBytes, int idx, int size)
  6. getByteNetOrderTo_unit32(byte[] theBytes, int idx)
  7. bitwiseAndByteArrays(byte[] arr0, byte[] arr1)
  8. bitwiseOrByteArrays(byte[] arr0, byte[] arr1)
  9. inverseByteArrayBits(byte[] arr0)