Android Byte Array to Int Convert toInteger(byte[] input)

Here you can find the source of toInteger(byte[] input)

Description

to Integer

License

Apache License

Declaration

public static int toInteger(byte[] input) 

Method Source Code

//package com.java2s;
/**//from   w  ww  .jav a  2 s.co  m
 * Source obtained from crypto-gwt. Apache 2 License.
 * https://code.google.com/p/crypto-gwt/source/browse/crypto-gwt/src/main/java/com/googlecode/
 * cryptogwt/util/ByteArrayUtils.java
 */

public class Main {
    public static int toInteger(byte[] input) {
        return toInteger(input, 0);
    }

    private static int toInteger(byte[] input, int offset) {
        assert offset + 4 <= input.length : "Invalid length "
                + input.length;
        return ((input[offset++] & 0xff) << 24)
                | ((input[offset++] & 0xff) << 16)
                | ((input[offset++] & 0xff) << 8)
                | ((input[offset++] & 0xff));
    }
}

Related

  1. byteArray2Int(byte[] bs)
  2. byteArrayToInt(byte[] b)
  3. toIntegerArray(byte[] input, int offset, int len)
  4. toIntegerArray(byte[] input, int offset, int len, int[] output, int outputOffset)
  5. toInt(byte[] bytes)
  6. toInteger(byte[] input, int offset)
  7. readInt(byte[] buff, int pos)
  8. getShort(byte[] data)
  9. getUnsignedSafe(byte[] buffer, int pos)