TextUtils { public static String toHexString(final byte[] bytes) { if (bytes == null) { return null; } final StringBuffer buffer = new StringBuffer(); for (int i = 0; i < bytes.length; i++) { final byte b = bytes[i]; if (b < 16) { buffer.append('0'); } buffer.append(Integer.toHexString(b & 0xff)); } return buffer.toString(); } private  TextUtils(); static boolean isEmpty(final CharSequence s); static boolean isBlank(final CharSequence s); static boolean containsBlanks(final CharSequence s); static String toHexString(final byte[] bytes);  }
@Test public void testToHexString() { Assert.assertEquals("000c2001", TextUtils.toHexString(new byte[] { 0, 12, 32, 1 })); Assert.assertEquals(null, TextUtils.toHexString(null)); }