String h="76F41000";
int re= new BigInteger(h, 16).intValue()
将10进制的数字转为16进制字符串
System.out.println("found items:" + ii + "==" + Integer.toHexString(startaddress + ii ));
String finalStr =Integer.toHexString(startaddress + ii );
将16进制字符串转为10进制的int(注意字符串不要以f开头,如有要先处理为0)
int kaishigezi = Integer.parseInt(beibaoshoukongge.getText(), 16);
将16进制字符串转为10进制的int(这种方法不需要处理ff开头的)
public static int OxStringtoInt(String ox) throws Exception {
ox=ox.toLowerCase();
if(ox.startsWith("0x")){
ox=ox.substring(2, ox.length() );
}
int ri = 0;
int oxlen = ox.length();
if (oxlen > 8)
throw (new Exception("too lang"));
for (int i = 0; i < oxlen; i++) {
char c = ox.charat(i);
int h;
if (('0' <= c && c <= '9')) {
h = c - 48;
} else if (('a' <= c && c <= 'f'))
{
h = c - 87;
}
else if ('A' <= c && c <= 'F') {
h = c - 55;
} else {
throw (new Exception("not a integer "));
}
byte left = (byte) ((oxlen - i - 1) * 4);
ri |= (h << left);
}
return ri;
}