bcd码转换成16进制的字符串
package com.xj.hhjk.common.util.transfor;
public class Bcd2HexStr {
/**
* bcd码转换成16进制的字符串
*
* @eg1:1234的bcd:[18,52]
* @eg2:123a的bcd:[18,58]
*
* @param bytes
* @return
*/
public static String convert(byte[] bytes) {
char stra[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
StringBuffer temp = new StringBuffer(bytes.length * 2);
for (int i = 0; i < bytes.length; i++) {
temp.append(stra[(bytes[i] & 0xf0) >> 4]);
temp.append(stra[bytes[i] & 0x0f]);
}
return temp.toString();
}
}
</