1,int与bytes 转换
int转换成bytes
public static final byte [] int2bytes ( int value )
{
return new byte []
{
( byte )( value >>> 24 ),
( byte )( value >>> 16 ),
( byte )( value >>> 8 ),
( byte ) value
};
}
4个byte转换成int
public static final int bytes2Int ( byte [] b s)
{
return{
( bs [ 0 ] << 24 )
+ (( bs [ 1 ] & 0xFF ) << 16 )
+ (( bs [ 2 ] & 0xFF ) << 8 )
+ ( b s[ 3 ] & 0xFF )
};
}