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

voidintToByte(byte[] buf, int off, int value)
int To Byte
buf[0 + off] = (byte) ((value >>> 24) & 0xFF);
buf[1 + off] = (byte) ((value >>> 16) & 0xFF);
buf[2 + off] = (byte) ((value >>> 8) & 0xFF);
buf[3 + off] = (byte) ((value >>> 0) & 0xFF);
byteintToByte(final int i)
Convert an integer (0 to 255) into a byte (-128 to 127).
int percent = (i * Byte.MAX_VALUE) / PERCENT_MAX;
byte ret = (byte) (percent & HEX_FF);
return ret;
byte[]intToByte(int i)
Converts a given integer value to a byte array
final byte[] b = new byte[4];
for (int j = 3; j >= 0; j--) {
    b[j] = (byte) (i & 0xFF);
    i >>= 8;
return b;
byteIntToByte(int i)
Int To Byte
return (byte) i;
byteintToByte(int i)
int To Byte
if (i < 255) {
    return (byte) (i & 0xFF);
} else {
    throw new NumberFormatException("Integer is more than 255 !");
ByteintToByte(int i)
int To Byte
if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) {
    return (byte) i;
return null;
byte[]intToByte(int i_Value)
int To Byte
byte[] v_Ret = new byte[4];
v_Ret[0] = (byte) ((i_Value >>> 24) & 0xFF);
v_Ret[1] = (byte) ((i_Value >>> 16) & 0xFF);
v_Ret[2] = (byte) ((i_Value >>> 8) & 0xFF);
v_Ret[3] = (byte) ((i_Value >>> 0) & 0xFF);
return v_Ret;
byteintToByte(int myInt)
Converts integer to byte value.
return (byte) (myInt & 0xff);
byteintToByte(int num)
int To Byte
byte high = (byte) ((num >> 4) & 0x0F);
byte low = (byte) (num & 0x0F);
byte value = (byte) ((high << 4) + low);
return value;
byteintToByte(int number)
Converts a int to a byte.
if (number <= 255 && number > 0)
    return (byte) number;
else
    return Byte.MIN_VALUE;