public static void main(String[] args) {
byte[] bytes1 = int2byte(200);
for (int i = 0; i < bytes1.length; i++) {
System.out.println(bytes1[i]);
}
System.out.println(byte2int(bytes1));
}
public static byte[] int2byte(int res) {
byte[] targets = new byte[4];
targets[0] = (byte) (res & 0xff);
targets[1] = (byte) ((res >> 8) & 0xff);
targets[2] = (byte) ((res >> 16) & 0xff);
targets[3] = (byte) (res >>> 24);
return targets;
}
网友评论