Android Byte Array to Int Convert getInts(int[] toInts, byte[] fromBytes)

Here you can find the source of getInts(int[] toInts, byte[] fromBytes)

Description

get Ints

License

Open Source License

Declaration

public static void getInts(int[] toInts, byte[] fromBytes) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static final int INT_SIZE = 4;

    public static void getInts(int[] toInts, byte[] fromBytes) {
        for (int intInd = 0; intInd < toInts.length; ++intInd) {
            final int fromInt = getInt(intInd * 4, fromBytes);
            int toInt = fromInt;
            toInts[intInd] = toInt;//  ww  w .j  a  v a  2  s . c  o  m
        }
    }

    public static void getInts(int[] toInts, byte[] fromBytes,
            int fromOffset) {
        for (int intInd = 0; intInd < toInts.length; ++intInd) {
            final int fromInt = getInt(fromOffset + (intInd * INT_SIZE),
                    fromBytes);
            int toInt = fromInt;
            toInts[intInd] = toInt;
        }
    }

    public static int getInt(int offset, byte[] fromBytes) {
        final int toInt;

        toInt = ((0xff & fromBytes[offset + 0]) << 24)
                | ((0xff & fromBytes[offset + 1]) << 16)
                | ((0xff & fromBytes[offset + 2]) << 8)
                | ((0xff & fromBytes[offset + 3]) << 0);

        return toInt;
    }
}

Related

  1. getIntFromByte(final byte bite)
  2. getIntFromByte(final byte bite)
  3. getIntFromByteArray(final byte[] byteArr)
  4. getIntFromByteArray(final byte[] bytes)
  5. getIntLE2(byte[] b, int offset)
  6. getInts(int[] toInts, byte[] fromBytes, int fromOffset)
  7. getUIntByByte(byte data)
  8. getUIntByByteArray(byte[] data)
  9. getUIntByByteArray(byte[] data, boolean isLH)