Java Utililty Methods Byte Array Create

List of utility methods to do Byte Array Create

Description

The list of methods to do Byte Array Create are organized into topic(s).

Method

byte[]toBytes(int data)
to Bytes
return new byte[] { (byte) (data >> 24), (byte) (data >> 16), (byte) (data >> 8), (byte) (data) };
byte[]toBytes(int data)
Converts an int to a byte array with 4 elements.
return new byte[] { (byte) ((data >> 24) & 0xff), (byte) ((data >> 16) & 0xff), (byte) ((data >> 8) & 0xff),
        (byte) ((data >> 0) & 0xff), };
byte[]toBytes(int i)
Convert an integer value into an byte array.
byte[] b = new byte[NUM_OCTETS_INTEGER];
setInt(b, 0, i);
return b;
byte[]toBytes(int i)
to Bytes
int step = 8;
for (; (i >>> step) > 0 && step < 32; step += 8)
    ;
byte[] b = new byte[step / 8];
for (int x = 0, move = step - 8; x < (step / 8); x++, move -= 8) {
    b[x] = (byte) (i >>> move);
return b;
...
byte[]toBytes(int i)
Converts the given integer into an array of bytes in network byte order.
return toBytes(i, 0, new byte[4]);
byte[]toBytes(int i)
to Bytes
if (i == Integer.MIN_VALUE)
    return minValue;
int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i);
byte[] buf = new byte[size];
getBytes(i, size, buf);
return buf;
byte[]toBytes(int i)
to Bytes
int shift = 8;
byte[] buf = new byte[4];
int pos = buf.length;
int radix = 1 << shift;
int mask = radix - 1;
do {
    buf[--pos] = (byte) (i & mask);
    i >>>= shift;
...
byte[]toBytes(int i)
to Bytes
byte[] result = new byte[4];
result[0] = (byte) (i >> 24);
result[1] = (byte) (i >> 16);
result[2] = (byte) (i >> 8);
result[3] = (byte) (i );
return result;
byte[]toBytes(int i)
to Bytes
byte[] b = new byte[4];
b[0] = (byte) (i & 0xff);
b[1] = (byte) ((i & 0xff00) >> 8);
b[2] = (byte) ((i & 0xff0000) >> 16);
b[3] = (byte) ((i & 0xff000000) >> 24);
return b;
byte[]toBytes(int integer)
Convert integer to byte array
sample: 0x037fb4c7 => {03, 7f, b4, c7}
byte[] result = new byte[4];
result[0] = (byte) (integer >> 24);
result[1] = (byte) (integer >> 16);
result[2] = (byte) (integer >> 8);
result[3] = (byte) (integer );
return result;