### Question:
B2StringUtil { public static String toHexString(byte[] b) { if (b == null || b.length == 0) { return ""; } StringBuilder sb = new StringBuilder(b.length * 2); for (int i = 0; i < b.length; i++) { int unsignedByte = (b[i] & 0xff); sb.append(LOWER_HEX_DIGITS[unsignedByte >> 4]); sb.append(LOWER_HEX_DIGITS[unsignedByte & 0x0f]); } return sb.toString(); } B2StringUtil(); static String percentEncode(String s); static String percentDecode(String s); static int decimalSubstringToInt(String s, int startIndex, int endIndex); static boolean decimalNumberInRange(String str, int offset, int length,
                                               int minInclusive, int maxInclusive); static String join(String delimiter, Object[] objects); static byte [] getUtf8Bytes(String str); static String toHexString(byte[] b); static String underscoresToCamelCase(String orig, boolean capitalizeFirstLetter); static boolean startsWithIgnoreCase(String all, String possiblePrefix); static final String UTF8; }### Answer:
@Test public void testToHexString() { assertEquals("", toHexString(null)); assertEquals("", toHexString(new byte[0])); assertEquals("abf0", toHexString(new byte[] {(byte) 0xab, (byte) 0xf0})); }