左晓为主开发手持机充值管理机
zuoxiao
2024-05-10 8c57cb70cc165d21fdda9385966e8ae65d36cc1d
baselibrary/src/main/java/com/dayu/baselibrary/tools/HexUtil.java
@@ -48,24 +48,11 @@
        for (int i = 0; i < byteList.size(); i++) {
            byteArray[i] = byteList.get(i);
        }
        String hex = bytesToHexNoAppen(byteArray);
        String hex = bytesToHex(byteArray);
        return Integer.parseInt(hex, 16);
    }
    /**
     * byte 数组转16进制字符串 不加0前缀
     *
     * @param bytes
     * @return
     */
    public static String bytesToHexNoAppen(byte[] bytes) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < bytes.length; i++) {
            String hex = Integer.toHexString(bytes[i] & 0xFF);
            sb.append(hex);
        }
        return sb.toString();
    }
    public static int getBcdToInt(byte data) {
        return ((data & 0xF0) >> 4) * 10 + ((data & 0x0F));
@@ -222,7 +209,7 @@
        for (int i = 0; i < byteList.size(); i++) {
            byteArray[i] = byteList.get(i);
        }
        String hex = bytesToHexNoAppen(byteArray);
        String hex = bytesToHex(byteArray);
        int intValue = Integer.parseInt(hex, 16); // 将十六进制字符串转换为整数表示
        float floatValue = Float.intBitsToFloat(intValue); // 将整数表示转换为浮点数
        return floatValue;
@@ -297,6 +284,10 @@
     * @return
     */
    public static String spaceHex(String str) {
        if (str.length() % 2 != 0) {
            //奇数时前面加0补齐称为偶数
            str = "0" + str;
        }
        char[] array = str.toCharArray();
        if (str.length() <= 2) return str;
        StringBuffer bufferHex = new StringBuffer();
@@ -317,7 +308,7 @@
     * @param str
     * @return
     */
    private static String HighLowHex(String str) {
    public static String HighLowHex(String str) {
        if (str.trim().length() <= 2) return str;
        List<String> list = Arrays.asList(str.split(" "));
        Collections.reverse(list);