Java Utililty Methods Integer Convert To

List of utility methods to do Integer Convert To

Description

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

Method

byte[]convertInt8(int v)
Convert 8-bits integer value to bytes arrays.
byte[] bytes = new byte[1];
bytes[0] = (byte) v;
return bytes;
Integer[]convertIntArray(int[] arr)
convert Int Array
Integer[] ret = new Integer[arr.length];
for (int i = 0; i < arr.length; i++) {
    ret[i] = arr[i];
return ret;
byte[]convertIntArray(int[] in)
This function converts an array of type int into an array of type byte
byte[] out = new byte[in.length];
for (int i = 0; i < in.length; i++) {
    out[i] = (byte) in[i];
return out;
intconvertIntArrayFromHex(char[] hex)
convert Int Array From Hex
int hexLen = hex.length;
if (hexLen < 8)
    throw new IllegalArgumentException("Too few characters: " + hexLen);
return (getHex(hex[0]) << 28) | (getHex(hex[1]) << 24) | (getHex(hex[2]) << 20) | (getHex(hex[3]) << 16)
        | (getHex(hex[4]) << 12) | (getHex(hex[5]) << 8) | (getHex(hex[6]) << 4) | (getHex(hex[7]));
intconvertIntBitsMSBinaryToIEEE(int source)
Converts a Microsoft Binary Float integer bits into a IEEE equivalent Assume all the bits are arrange in a the big endian format
int mantissa = source & 0x007FFFFF;
int sign = (source & 0x00800000) >> 23;
int exponent = (source & 0xFF000000) >>> 24;
exponent = exponent - 0x81 + 0x7F; 
sign = sign << 31;
exponent = exponent << 23;
int retVal = mantissa | sign | exponent;
return retVal;
...
byte[]convertIntColourToByteArray(int intColour)
convert Int Colour To Byte Array
byte[] colourByteArray = new byte[3];
colourByteArray[0] = (byte) (intColour >> 16 & 255);
colourByteArray[1] = (byte) (intColour >> 8 & 255);
colourByteArray[2] = (byte) (intColour & 255);
return colourByteArray;
double[][]convertIntDouble(int[][] in)
Convert an integer 2-D array to a double array.
double[][] ret = new double[in.length][in[0].length];
for (int i = 0; i < in.length; i++) {
    for (int j = 0; j < in.length; j++)
        ret[i][j] = (double) in[i][j];
return ret;
StringconvertInteger(String input, int maxLen)
convert Integer
int output = 0;
int idx = maxLen;
if (input.length() < maxLen) {
    idx = input.length();
try {
    output = Integer.parseInt(input.substring(0, idx));
} catch (Exception e) {
...
IntegerconvertInteger(String str)
convert Integer
int val = 0;
try {
    val = Integer.parseInt(str);
} catch (NumberFormatException ex) {
return new Integer(val);
int[]convertIntegerArrayToInt(Integer[] integerArray)
convert Integer Array To Int
int[] intArray = new int[integerArray.length];
for (int i = 0; i < integerArray.length; i++) {
    intArray[i] = integerArray[i];
return intArray;