Revision as of 04:29, 23 November 2010 by Han84 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
/**
 * Represent the byte array into hex digits. Two hex digits represent one byte.
 * @param data
 * @param length
 * @return
 */
public static String convertByteArrayToHex(byte[] data, int length) {
	String digits = "0123456789abcdef";
	StringBuilder buf = new StringBuilder();
	for (int i = 0; i != length; i++) {
		int v = data[i] & 0xff;
		buf.append(digits.charAt(v >> 4));
		buf.append(digits.charAt(v & 0xf));
	}
	return buf.toString();
}


Back to JavaHowTo

Alumni Liaison

has a message for current ECE438 students.

Sean Hu, ECE PhD 2009