Files
ElderlyAssistant/app/src/main/java/com/ttstd/elderlyassistant/utils/HexUtils.java

16 lines
432 B
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.ttstd.elderlyassistant.utils;
public class HexUtils {
// 字节数组转16进制字符串优化版
public static String bytesToHexString(byte[] bytes) {
if (bytes == null) return "";
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
sb.append(String.format("%02X", b)); // 直接格式化为大写16进制
}
return sb.toString();
}
}