package iso;
public class Test5 {
/** * @param b
* 16进制数 转换成字符串形式
* @return
*/
public static String byte2hex(byte[] b) {
String hs = "";
String stmp = "";
for (int i = 0; i < b.length; i++) {
stmp = Integer.toHexString(b[i] & 0xFF);
if (stmp.length() == 1) {
hs += stmp;
} else {
hs += stmp;
}
}
return hs.toUpperCase();
}
public static void main(String[] args) {
byte[] str1= new byte[]{12,4};
System.out.println(byte2hex(str1));
}
}