Java Utililty Methods Int to Byte Array

List of utility methods to do Int to Byte Array

Description

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

Method

byte[]intTobyte2(int i)
int Tobyte
byte[] tagbytes = new byte[2];
tagbytes[1] = (byte) (0xff & i);
tagbytes[0] = (byte) ((0xff00 & i) >> 8);
return tagbytes;
byte[]intToByte2Array(int x)
int To Byte Array
byte[] buf = new byte[2];
buf[1] = (byte) ((x & 0x0000ff00) >>> 8);
buf[0] = (byte) ((x & 0x000000ff));
return buf;
byte[]UIntToByte2(int value)
U Int To Byte
if (value < 0)
    value = 0;
if (value > Short.MAX_VALUE)
    value = Short.MAX_VALUE;
value += Short.MIN_VALUE;
return new byte[] { (byte) (value >>> 8), (byte) value };