62,612
社区成员
发帖
与我相关
我的任务
分享
public static int atoi(byte[] bytes) {
return Integer.parseInt("0"+ new String(bytes).replaceAll("(?s)\\D.*", ""), 10);
}
public static void main(String[] args) {
System.out.println(
atoi(new byte[] { 0x39, 0x69, (byte)0xcc, 0x55 })
);
}
public static String bytes2HexString(byte[] b) {
String ret = "";
for (int i = 0; i < b.length; i++) {
String hex = Integer.toHexString(b[ i ] & 0xFF);
if (hex.length() == 1) {
hex = '0' + hex;
}
ret += hex.toUpperCase();
}
return ret;
}