High and low bit hexadecimal string conversion

/**
     * 十六进制字符串高低位转换
     * @param lockAddress
     * @return
     */
    private static String lockAddress(String lockAddress) {
        
        StringBuffer s1 = new StringBuffer(lockAddress);
        int index;
        for (index = 2; index < s1.length(); index += 3) {
            s1.insert(index, ',');
        }
        String[] array = s1.toString().split(",");
        String[] swapOrder = swapOrder(array);
        StringBuffer s2 = new StringBuffer();
        for (String str :swapOrder ) {
            s2.append(str);
        }
        return s2.toString();
         
    }
     

test:

System.out.println (lockAddress ( "dc45fd45") ); // output: 45fd45dc
        System.out.println (lockAddress ( "011e9e")); // output: 9e1e01

Published 141 original articles · won praise 33 · views 50000 +

Guess you like

Origin blog.csdn.net/qq_43560721/article/details/103054983