Java Utililty Methods Integer to Byte

List of utility methods to do Integer to Byte

Description

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

Method

byte[]int2ByteArray(int i)
int Byte Array
byte[] result = new byte[4];
result[0] = (byte) ((i >> 24) & 0xFF);
result[1] = (byte) ((i >> 16) & 0xFF);
result[2] = (byte) ((i >> 8) & 0xFF);
result[3] = (byte) (i & 0xFF);
return result;
voidint2byteArray(int k, byte b[], int off)
intbyte Array
int j;
j = b.length;
if (b == null || j <= off) {
    return;
j -= off;
if (j > INT_BYTES) {
    j = INT_BYTES;
...
byte[]int2ByteArray(int value)
int Byte Array
byte[] b = new byte[4];
for (int i = 0; i < 4; i++) {
    int offset = (3 - i) * 8;
    b[i] = (byte) ((value >>> offset) & 0xFF);
return b;
byte[]int2byteArray(int[] i)
intbyte Array
byte[] b = new byte[i.length];
for (int x = 0; x < i.length; x++) {
    int t = i[x];
    if (t > 128) {
        t -= 256;
    b[x] = (byte) t;
return b;
byte[]int2ByteArrayLength4(int theInt)
int Byte Array Length
byte[] byteLong = new byte[4];
byteLong[0] = (byte) ((theInt >>> 24) & 0xff);
byteLong[1] = (byte) ((theInt >>> 16) & 0xff);
byteLong[2] = (byte) ((theInt >>> 8) & 0xff);
byteLong[3] = (byte) ((theInt) & 0xff);
return byteLong;
byte[]int2ToByteArray(int value)
int To Byte Array
return new byte[] { (byte) (value >>> 8), (byte) value };
byteint2ubyte(int in)
intubyte
in = ((in < 0) ? 0 - in : in) % 256;
return (in > 127) ? (byte) (in - 256) : (byte) in;
byteintAsByte(int value)
int As Byte
return (byte) (value & 0xff);
byte[]intTo1Byte(int x)
int To Byte
byte[] out = new byte[1];
out[0] = (byte) (x & 0xff);
return out;
byte[]intTo4Byte(int i)
int To Byte
return numberToByte(i, 4);