首页 > 代码库 > java 16进制转换10进制

java 16进制转换10进制

public static String toHexString2(byte[] b) {
		StringBuffer buffer = new StringBuffer();
		for (int i = 0; i < b.length; ++i) {
			buffer.append(toHexString2(b[i]));
		}
		return buffer.toString();
	}

	public static String toHexString2(byte b) {
		char[] buffer = new char[2];
		buffer[0] = Character.forDigit((b >>> 4) & 0x0F, 16);
		buffer[1] = Character.forDigit(b & 0x0F, 16);
		return new String(buffer);
	}