13,097
社区成员




/**
* Int to byte[]
*
* @param value
* @return byte[]
*/
public static byte[] intToByteArray1(int value)
{
byte[] byteA = new byte[4];
//
byteA[0] = (byte) (value >> 24);
byteA[1] = (byte) (value >> 16);
byteA[2] = (byte) (value >> 8);
byteA[3] = (byte) value;
return byteA;
}
/**
* byte[]toInt
*
* @param byteArray
* @return
*/
public static int byteArrayToInt(byte[] byteArray)
{
int mask = 0xff;
int temp = 0;
int n = 0;
int length=byteArray.length;
for (int i = 0; i < length; i++)
{
n <<= 8;
temp = byteArray[i] & mask;
n |= temp;
}
return n;
}