List of utility methods to do Int to Byte Array Convert
void | uInt16ToBytesBI(int value, byte[] buffer, int startIndex) u Int To Bytes BI buffer[startIndex++] = (byte) (value >>> 8); buffer[startIndex++] = (byte) (value >>> 0); |
byte[] | uInt16ToBytesLI(int value) u Int To Bytes LI byte b[] = new byte[2]; uInt16ToBytesLI(value, b, 0); return b; |
void | uInt16ToBytesLI(int value, byte[] buffer, int startIndex) u Int To Bytes LI buffer[startIndex++] = (byte) (value >>> 0); buffer[startIndex++] = (byte) (value >>> 8); |
byte[] | uInt32ToBytesBI(long value) u Int To Bytes BI byte b[] = new byte[4]; uInt32ToBytesBI(value, b, 0); return b; |
void | uInt32ToBytesBI(long value, byte[] buffer, int startIndex) u Int To Bytes BI buffer[startIndex++] = (byte) (value >>> 24); buffer[startIndex++] = (byte) (value >>> 16); buffer[startIndex++] = (byte) (value >>> 8); buffer[startIndex++] = (byte) (value >>> 0); |
byte[] | uInt32ToBytesLI(long value) u Int To Bytes LI byte b[] = new byte[4]; uInt32ToBytesLI(value, b, 0); return b; |
void | uInt32ToBytesLI(long value, byte[] buffer, int startIndex) u Int To Bytes LI buffer[startIndex++] = (byte) (value >>> 0); buffer[startIndex++] = (byte) (value >>> 8); buffer[startIndex++] = (byte) (value >>> 16); buffer[startIndex++] = (byte) (value >>> 24); |
byte[] | toByteArray(int in) to Byte Array byte[] out = new byte[4]; out[0] = (byte) in; out[1] = (byte) (in >> 8); out[2] = (byte) (in >> 16); out[3] = (byte) (in >> 24); return out; |
byte[] | toByteArray(int in, int outSize) to Byte Array byte[] out = new byte[outSize]; byte[] intArray = toByteArray(in); for (int i = 0; i < intArray.length && i < outSize; i++) { out[i] = intArray[i]; return out; |
void | toByteArray(int val, byte[] b, int pos) to Byte Array assert (pos + 4 <= b.length); for (int i = 0; i < 4; ++i) { b[pos + i] = (byte) (val & 0x000000FF); val = val >> 8; |