List of utility methods to do Int to Byte Array Convert
byte[] | ints2bytesBE(int[] val) intsbytes BE if (val == null) return null; byte[] b = new byte[val.length << 2]; for (int i = 0; i < val.length; i++) int2bytesBE(val[i], b, i << 2); return b; |
byte[] | ints2bytesLE(int[] val) intsbytes LE if (val == null) return null; byte[] b = new byte[val.length << 2]; for (int i = 0; i < val.length; i++) int2bytesLE(val[i], b, i << 2); return b; |
byte[] | intsToBytes(int[] values) ints To Bytes byte[] ret = new byte[values.length]; for (int k = 0, len = values.length; k < len; k++) ret[k] = (byte) values[k]; return ret; |
byte[] | getAs_uint16_NetOrder(int theNumber) turn 16 bits unsigned integer number to byte array representing the number in network order. byte[] toReturn = new byte[2]; toReturn[0] = (byte) (theNumber & 0xf0); toReturn[1] = (byte) (theNumber & 0x0f); return toReturn; |
byte[] | getAs_uint32_NetOrder(int theNumber) turn 32 bits unsigned integer number to byte array representing the number in network order. byte[] toReturn = new byte[4]; toReturn[0] = (byte) ((theNumber >> 24) & 0xff0); toReturn[1] = (byte) ((theNumber >> 16) & 0xff); toReturn[2] = (byte) ((theNumber >> 8) & 0xff); toReturn[3] = (byte) (theNumber & 0xff); return toReturn; |
void | toBytes(int integer, byte[] output, int offset) to Bytes assert output.length - offset >= 4; int i = offset; output[i++] = (byte) (integer >>> 24); output[i++] = (byte) (integer >>> 16); output[i++] = (byte) (integer >>> 8); output[i++] = (byte) (integer & 0xff); |
byte[] | int2ByteArray(int num) int Byte Array byte[] b = new byte[4]; b[0] = (byte) (num >>> 24); b[1] = (byte) (num >>> 16); b[2] = (byte) (num >>> 8); b[3] = (byte) num; return b; |
byte[] | int2ByteArrayBigEndian(int num) int Byte Array Big Endian return int2ByteArray(num); |
byte[] | int2ByteArrayLittleEndian(int num) int Byte Array Little Endian byte[] b = new byte[4]; b[3] = (byte) (num >>> 24); b[2] = (byte) (num >>> 16); b[1] = (byte) (num >>> 8); b[0] = (byte) num; return b; |