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

inttoInt(byte[] data)
Convert byte array to int
if (data == null || data.length != 4)
    return 0x0;
return (int) ((0xff & data[0]) << 24 | (0xff & data[1]) << 16 | (0xff & data[2]) << 8
        | (0xff & data[3]) << 0);
longtoInt(byte[] data)
Translates a network order byte representation of an int back into a java primitive.
return toInt(data, 0);
inttoInt(byte[] data, int offset, int length)
to Int
int value = 0;
for (int i = offset; i < (offset + length); i++) {
    final byte b = data[i];
    value = (value << 8) | (b >= 0 ? (int) b : (b + 256));
return value;
inttoInt(byte[] in)
to Int
int out = 0;
for (int i = in.length - 1; i > 0; i--) {
    out |= in[i] & 0xff;
    out <<= 8;
out |= in[0] & 0xff;
return out;
inttoInt(byte[] in)
to Int
return toInt(in[0], in[1], in[2], in[3]);
inttoInt(byte[] input)
Converts a given byte array to an int .
assert input.length == 4 : "toInt(): Byte array length must be 4.";
int output = 0;
output = ((input[0] & 0xff) << 24) | ((input[1] & 0xff) << 16) | ((input[2] & 0xff) << 8)
        | (input[3] & 0xff);
return output;
inttoInt(byte[] key)
to Int
assert isInt(key);
return (((key[0] & 255) << 24) + ((key[1] & 255) << 16) + ((key[2] & 255) << 8) + (key[3] & 255));
inttoInt(byte[] n)
Converter
int a = n[0];
if (a < 0) {
    a += 256;
int b = n[1];
if (b < 0) {
    b += 256;
int c = n[2];
if (c < 0) {
    c += 256;
int d = n[3];
if (d < 0) {
    d += 256;
return a + b * 256 + c * 65536 + d * 16777216;
inttoInt(byte[] readBuffer, int o)
to Int
int ch1 = readBuffer[o++];
int ch2 = readBuffer[o++];
int ch3 = readBuffer[o++];
int ch4 = readBuffer[o++];
if ((ch1 | ch2 | ch3 | ch4) < 0)
    throw new IllegalStateException();
return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
inttoInt(byte[] res)
to Int
return (res[0] & 0xff) | ((res[1] << 8) & 0xff00) | ((res[2] << 24) >>> 8) | (res[3] << 24);