如何把一個byte數(shù)組的數(shù)字轉(zhuǎn)換成int?
int轉(zhuǎn)byte數(shù)組publicstaticbyte[]intToBytes2(intn){byte[]b=newbyte[4];for(inti=0;i<4;i++){b[i]=(byte)(n>>(24-i*8));}returnb;}byte轉(zhuǎn)換為intpublicstaticintbyteToInt2(byte[]b){intmask=0xff;inttemp=0;intn=0;for(inti=0;i<b.length;i++){n<<=8;temp=b[i]&mask;n|=temp;}returnn;}
上一篇為什么不能用默認null
下一篇如何從c語言過渡到c