/** * 十六进制高低位转换,返回十进制数 * @param str * @return */ public static String decodeHexStringToDec(String str) { str =HighLowHex(spaceHex(str)); String value =new BigInteger(str, 16).toString(); return value; } /** * 十六进制数隔空位 * @param str * @return */ private static String spaceHex(String str){ char[] array= str.toCharArray(); if(str.length()<=2) return str; StringBuffer buffer =new StringBuffer(); for(int i=0;i<array.length;i++){ int start =i+1; if(start%2==0){ buffer.append(array[i]).append(" "); }else{ buffer.append(array[i]); } } return buffer.toString(); } /** * 高位16进制转低位 * @param str * @return */ private static String HighLowHex(String str){ if(str.trim().length()<=2) return str; List<String> list = Arrays.asList( str.split(" ")); Collections.reverse(list); StringBuffer stringBuffer = new StringBuffer(); for(String string:list){ stringBuffer.append(string); } return stringBuffer.toString(); }
原文地址:https://www.cnblogs.com/huyanlon/p/10337634.html
时间: 2024-10-09 14:23:20