Java Utililty Methods Integer Create

List of utility methods to do Integer Create

Description

The list of methods to do Integer Create are organized into topic(s).

Method

inttoInteger(byte[] b)
Convert a 4 bytes array into an integer number.
if (b.length != NUM_OCTETS_INTEGER) {
    throw new IllegalArgumentException("Invalid byte array length: " + b.length);
int index = 0;
int value = (b[index++] & MASK_BYTE) << INT_SHIFT_OCTET1;
value |= (b[index++] & MASK_BYTE) << INT_SHIFT_OCTET2;
value |= (b[index++] & MASK_BYTE) << INT_SHIFT_OCTET3;
return value | (b[index] & MASK_BYTE);
...
inttoInteger(byte[] b)
Converts the bytes in an array into the corresponding integer value.
return toInteger(b, 0);
inttoInteger(byte[] bytes)
to Integer
return ((bytes[0] & 0xff) << 24) | ((bytes[1] & 0xff) << 16) | ((bytes[2] & 0xff) << 8) | (bytes[3] & 0xff);
inttoInteger(byte[] bytes)
Convert a byte array to an integer.
return toInteger(bytes, true);
inttoInteger(byte[] bytes, int index)
Convert the necessary number of bytes starting at the given index to an int.
int val = 0;
int typeBytes = Integer.SIZE / Byte.SIZE;
checkBounds(bytes, index, typeBytes);
for (int i = 0; i < typeBytes; i++) {
    int b = bytes[index++];
    b = (b < 0) ? b + 256 : b;
    int shiftBits = Byte.SIZE * (typeBytes - i - 1);
    val += (b << shiftBits);
...
inttoInteger(byte[] input)
to Integer
return toInteger(input, 0);
inttoInteger(E val)
to Integer
@SuppressWarnings("unchecked")
E[] vals = (E[]) val.getClass().getEnumConstants();
for (int idx = 0; idx < vals.length; idx++) {
    if (vals[idx] == val)
        return idx;
throw new IllegalArgumentException();
inttoInteger(final byte[] data)
Converts the 4-byte array to a Big Endian int.
if (data.length != 4) {
    throw new IllegalArgumentException("data must be of length 4");
return toInteger(data, 0);
IntegertoInteger(final Double value)
to Integer
Integer integerValue = null;
if (value != null) {
    integerValue = value.intValue();
return integerValue;
inttoInteger(final Object o)
Metodo que devuelve un numero de tipo Int a partir de un String
return Integer.parseInt(String.valueOf(o));