public static byte[] int2ByteArray(int data) { byte[] buf = new byte[4]; buf[3] = (byte) ((data >> 24) & 0xff); buf[2] = (byte) ((data >> 16) & 0xff); buf[1] = (byte) ((data >> 8) & 0xff); buf[0] = (byte) (data & 0xff); return buf; }
public static int byteArray2Int(byte[] data) { return ((data[0] & 0xff) << 24) | ((data[1] & 0xff) << 16) | ((data[2] & 0xff) << 8) | (data[3] & 0xff); }