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

int[][]toInt(double[][] data)
to Int
int[][] newdata = new int[data.length][];
for (int r = 0; r < data.length; r++) {
    newdata[r] = new int[data[r].length];
    for (int c = 0; c < data[r].length; c++)
        newdata[r][c] = (int) data[r][c];
return newdata;
int[][]toInt(double[][] doubles)
to Int
final int width = doubles.length;
final int height = doubles[0].length;
double max = 0;
for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
        max = Math.max(max, doubles[x][y]);
int[][] ints = new int[width][height];
for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
        ints[x][y] = (int) Math.rint((doubles[x][y] * 255) / max);
return ints;
inttoInt(final Boolean value)
To int.
if (value == null) {
    return FALSE_INT;
return toInt(value.booleanValue());
inttoInt(final byte b)
Converts an unsigned byte to an int, ie treating the bits in the byte as the low 8 bits in the int (ie the eigth bit is not treated as a sign bit).
return b & 0xff;
inttoInt(final byte b)
Converts a byte to an integer as 2 ˆ 8 + 2 ˆ 7 + 2 ˆ 6 + 2 ˆ 5 + 2 ˆ 4 + 2 ˆ 3 + 2 ˆ 2 + 2 ˆ 1 + 2 ˆ 0
int value = 0;
for (int i = 0; i < 8; i++) {
    if ((b & 1 << i) > 0) {
        value += Math.pow(2, i);
return value;
inttoInt(final byte[] buffer, final int offset, final int length)
to Int
int ret = 0;
final int done = offset + length;
for (int i = offset; i < done; i++) {
    ret = ((ret << 8) & 0xffffffff) + (buffer[i] & 0xff);
return ret;
inttoInt(final byte[] bytes, final int offset)
to Int
final byte b1 = bytes[offset];
final byte b2 = bytes[offset + 1];
final byte b3 = bytes[offset + 2];
final byte b4 = bytes[offset + 3];
return b1 << 24 | (b2 & 0xFF) << 16 | (b3 & 0xFF) << 8 | b4 & 0xFF;
inttoInt(final byte[] bytes, final int offset)
Returns the integer representation of an array of bytes from a given offset.
int output = 0;
if (bytes == null) {
    return output;
for (int i = 0; i < 4 && i + offset < bytes.length; i++) {
    output <<= 8;
    output |= bytes[i] & 0xFF;
return output;
inttoInt(final byte[] data)
Converts the big-endian representation of a 32-bit integer to the equivalent integer value.
return (data[0] << 24) | ((data[1] & 0xff) << 16) | ((data[2] & 0xff) << 8) | (data[3] & 0xff);
inttoInt(final byte[] inputBytes, int offset)
Form a integer value reading 4 bytes
int intVal = (inputBytes[offset] << 24) + ((inputBytes[++offset] & 0xff) << 16)
        + ((inputBytes[++offset] & 0xff) << 8) + (inputBytes[++offset] & 0xff);
return intVal;