HexUtils { public static String dump(final byte[] data) { if (null == data) { return "<<null>>"; } return dump(data, 0, data.length); }  static String encode(final byte[] bytes); static String encodeLower(final byte[] bytes); static byte[] decode(final String str); static String dump(final byte[] data); static String dump(final byte[] data, final int offset, final int length); static void dump(final byte[] data, final int offset, final int length,
      final Writer writer);  }
@Test public void testDump() throws Exception { byte[] bytes = new byte[1024]; assertTrue(bytes.length < HexUtils.dump(bytes).length()); for (int i = 0; i < testcase.length; i++) { final ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); final StringReader reader = new StringReader(testcase[i]); try { assertTrue(0 == (testcase[i].length() % 2)); char[] characters = new char[2]; while (2 == reader.read(characters)) { byteOut.write((byte) Integer.parseInt(new String(characters), 16)); } assertNotNull(dump(byteOut.toByteArray())); } finally { close(byteOut, true); closeQuietly(reader); } } }