如何将int类型数据转换成byte数组

it2022-05-09  33

public byte[] intTobytes(int number,byte[] source)   {     byte [] ret=null;     if(source.length<2)       ret = new byte[2];     else       ret = source;     //converter here      ret[0]=(byte)(number&0xff);      ret[1]=(byte)((number>>8)&0xff);//还可以转换成4个字节的。     return ret;   }

转载于:https://www.cnblogs.com/tuyile006/archive/2006/06/23/434083.html


最新回复(0)