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

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

Description

get Ints

License

Open Source License

Declaration

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

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;//from   w w w  . ja  va2 s . co  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. getIntFromByteArray(final byte[] byteArr)
  3. getIntFromByteArray(final byte[] bytes)
  4. getIntLE2(byte[] b, int offset)
  5. getInts(int[] toInts, byte[] fromBytes)
  6. getUIntByByte(byte data)
  7. getUIntByByteArray(byte[] data)
  8. getUIntByByteArray(byte[] data, boolean isLH)
  9. toInt(byte[] src)