List of utility methods to do Integer to Byte Array
byte[] | convertIntegersToBytes(int[] integers) This function converts an int integer array to a byte array.
if (integers != null) { byte[] outputBytes = new byte[integers.length * 4]; for (int i = 0, k = 0; i < integers.length; i++) { int integerTemp = integers[i]; for (int j = 0; j < 4; j++, k++) { outputBytes[k] = (byte) ((integerTemp >> (8 * j)) & 0xFF); return outputBytes; } else { return null; |
byte[] | convertIntegerToByteArray(int value, int bytes, boolean revers) convert Integer To Byte Array if (bytes == 1 && !revers) { return new byte[] { (byte) value }; } else if (bytes == 1 && revers) { return new byte[] { (byte) (value >>> 24) }; } else if (bytes == 2 && !revers) { return new byte[] { (byte) (value >>> 8), (byte) value }; } else if (bytes == 2 && revers) { return new byte[] { (byte) (value >>> 24), (byte) (value >>> 16) }; ... |
byte[] | convertIntToByteArray(int value) convert Int To Byte Array int originValue = value; int size = 0; if (value < 0) { value = -value; while (value > sizeTable[size]) size++; size++; ... |
byte[] | convertIntToByteArray(int value, int numberOfBytes) convert Int To Byte Array byte b[] = new byte[numberOfBytes]; int i, shift; for (i = 0, shift = (b.length - 1) * 8; i < b.length; i++, shift -= 8) { b[i] = (byte) (0xFF & (value >> shift)); return b; |
byte[] | convertIntToByteArray(int[] rgb) Converts the given int[] array into a byte[] array byte[] data = new byte[rgb.length * 4]; int j = 0; for (int i = 0; i < rgb.length; i++) { int v = rgb[i]; data[j + 0] = (byte) ((v >>> 24) & 0xFF); data[j + 1] = (byte) ((v >>> 16) & 0xFF); data[j + 2] = (byte) ((v >>> 8) & 0xFF); data[j + 3] = (byte) ((v >>> 0) & 0xFF); ... |
byte[] | convertIntToBytes(int i) convert Int To Bytes byte[] b = new byte[4]; b[0] = (byte) (0xff & i); b[1] = (byte) ((0xff00 & i) >> 8); b[2] = (byte) ((0xff0000 & i) >> 16); b[3] = (byte) ((0xff000000 & i) >> 24); return b; |
byte[] | fromIntToByte(int integer) from Int To Byte String s = String.valueOf(integer); byte[] b = new byte[s.length()]; for (int i = 0; i < s.length(); i++) { b[i] = (byte) s.charAt(i); return b; |
byte[] | fromIntToByteArray(int value) from Int To Byte Array return new byte[] { (byte) (value >>> 24), (byte) (value >>> 16), (byte) (value >>> 8), (byte) value }; |
void | int2Arr(int var, byte[] arrayBytes, int startIndex) Write the bytes of "var" into new byte array. int length = 4; if (arrayBytes != null && startIndex + length <= arrayBytes.length) { for (int j = startIndex; j < startIndex + length; j++) { arrayBytes[j] = (byte) var; var >>= 8; |
void | int2ByteLE(byte[] bytes, int value, int offset) int Byte LE checkLength(bytes, 4, offset); bytes[offset + 0] = (byte) ((value & 0xff)); bytes[offset + 1] = (byte) ((value >> 8 * 1) & 0xff); bytes[offset + 2] = (byte) ((value >> 8 * 2) & 0xff); bytes[offset + 3] = (byte) ((value >> 8 * 3)); |