public static byte[] toByteClass(String msg){
byte[] bt= new byte[2];
int res = Integer.parseInt(msg);
int num = Integer.parseInt(Integer.toHexString(res));
bt[0] = (byte) ((res >> 8) & 0xff);// 次低位
bt[1] = (byte) (res & 0xff);// 最低位
// bt[2] = (byte) ((res >> 16) & 0xff);// 次高位
// bt[3] = (byte) (res >>> 24);// 最高位,无符号右移。
return bt;
}
java中将int型数据转换成byte字节数组
最新推荐文章于 2024-08-15 02:15:24 发布