List of utility methods to do Integer to Byte Array
void | intToByteArray(final int v, final byte[] buf, final int offset) int To Byte Array buf[offset + 0] = (byte) ((v >> 24) & 0xFF); buf[offset + 1] = (byte) ((v >> 16) & 0xFF); buf[offset + 2] = (byte) ((v >> 8) & 0xFF); buf[offset + 3] = (byte) ((v >> 0) & 0xFF); |
void | intToByteArray(final int val, final byte[] buf, final int offset) Copies the byte representation of an int into a byte array starting at the given offset buf[offset + 0] = (byte) (val >>> 24); buf[offset + 1] = (byte) (val >>> 16); buf[offset + 2] = (byte) (val >>> 8); buf[offset + 3] = (byte) (val); |
byte[] | intToByteArray(final int value) Int to byte array. return new byte[] { (byte) (value >>> 24), (byte) (value >>> 16), (byte) (value >>> 8), (byte) value }; |
byte[] | intToByteArray(final int x) Convert an integer to a byte array. final byte[] bytes = new byte[4]; bytes[3] = (byte) (x & 0x000000ff); bytes[2] = (byte) ((x & 0x0000ff00) >>> 8); bytes[1] = (byte) ((x & 0x00ff0000) >>> 16); bytes[0] = (byte) ((x & 0xff000000) >>> 24); return bytes; |
void | intToByteArray(final int x, final byte[] dst, final int offset) Convert an integer to a byte array. dst[offset + 3] = (byte) (x & 0x000000ff); dst[offset + 2] = (byte) ((x & 0x0000ff00) >>> 8); dst[offset + 1] = (byte) ((x & 0x00ff0000) >>> 16); dst[offset + 0] = (byte) ((x & 0xff000000) >>> 24); |
byte[] | intToByteArray(int a) Returns four bytes represented by int. return new byte[] { (byte) ((a >> 24) & 0xFF), (byte) ((a >> 16) & 0xFF), (byte) ((a >> 8) & 0xFF), (byte) (a & 0xFF) }; |
byte[] | intToByteArray(int a) int To Byte Array return new byte[] { (byte) ((a >> 24) & 0xFF), (byte) ((a >> 16) & 0xFF), (byte) ((a >> 8) & 0xFF), (byte) (a & 0xFF) }; |
byte[] | intToByteArray(int bytes) Turn integer into 4 byte array representation return new byte[] { (byte) ((bytes >>> 24) & 0xff), (byte) ((bytes >>> 16) & 0xff), (byte) ((bytes >>> 8) & 0xff), (byte) ((bytes) & 0xff) }; |
byte[] | intToByteArray(int data) Converts the given integer value to a byte type array in Little endian order. byte[] result = new byte[4]; result[0] = (byte) (data & 0xff); result[1] = (byte) ((data >>> 8) & 0xff); result[1] = (byte) ((data >>> 16) & 0xff); result[1] = (byte) ((data >>> 24) & 0xff); return result; |
byte[] | intToByteArray(int i) Convert from one int to a byte array return new byte[] { (byte) (i >> 24), (byte) (i >> 16), (byte) (i >> 8), (byte) i }; |