java中byte转换int时为何与0xff进行与运算
在剖析该问题前请看如下代码
public static String bytes2HexString(byte[] b) {
String
ret = "";
for (int i = 0; i
String hex =
Integer.toHexString(b[ i ] & 0xFF);
if (hex.length() == 1) {
hex = '0' + hex;
}
ret += hex.toUpperCase();
}
转载
2010-11-22 17:33:00 ·
331 阅读 ·
0 评论