packagecom.util;/***@评释106入造取10入造之间的退换*@author崔素强*@version1.0*@since*/publicclassByteAndStr16{privatefinalstaticbyte[]hex="0123456789ABCDEF".getBytes();privatestaticintparse(charc){if(c>='a')return(c-'a'+10)&0x0f;if(c>='A')return(c-'A'+10)&0x0f;return(c-'0')&0x0f;}//从字节数组到106入造字符串蜕变publicstaticStringBytes2HexString(byte[]b){byte[]buff=newbyte[3*b.length];for(inti=0;i<b.length;i++){buff[3*i]=hex[(b[i]>>4)&0x0f];buff[3*i+1]=hex[b[i]&0x0f];buff[3*i+2]=45;}Stringre=newString(buff);returnre.replace("-","");}//从106入造字符串到字节数组调换publicstaticbyte[]HexString2Bytes(Stringhexstr){hexstr=hexstr.replace("","");byte[]b=newbyte[hexstr.length()/2];intj=0;for(inti=0;i<b.length;i++){charc0=hexstr.charAt(j++);charc1=hexstr.charAt(j++);b[i]=(byte)((parse(c0)<<4)|parse(c1));}returnb;}}
英文称呼:hexadecimal number system,是估计机中数据的1种显示办法。
共尔们通常中便表现法没有一致。它由0-9,A-F构成,字母没有分辨年夜小写。取10入造的对于应联系是:0-9对于应0-9;A-F对于应10-15;N入造的数能够用0---(N-1)的数标明,超越9的用字母A-F。
推举您浏览更多相关于“ 更换10入造106入造 ”的作品