1 /** 2 3 * Hex格式数据转换成十六进制字符串 4 5 * @param src 6 7 */ 8 9 public void bytesToHexString(byte[] by){ 10 StringBuilder stringBuilder = new StringBuilder(""); 11 for (int i = 0; i < by.length; i++) { 12 int in = by[i] & 0xFF; 13 String str= Integer.toHexString(in); 14 if (str.length() < 2) { 15 stringBuilder.append(0); 16 } 17 stringBuilder.append(str); 18 } 19 System.out.println(stringBuilder.toString()); 20 }
时间: 2024-10-13 13:42:35