HexUtils { public static byte[] decode(final String str) { final StringReader reader = new StringReader(str); final ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); int ch1 = 0; try { while (0 < (ch1 = reader.read())) { int ch2 = reader.read(); assertTrue(0 <= ch2); byteOut.write(convert(ch1) << 4 | convert(ch2)); } return byteOut.toByteArray(); } catch (final IOException e) { throw new IllegalStateException(e); } }  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 testDecode() throws Exception { assertArrayEquals( new byte[] { (byte) 0xE2, (byte) 0x08, (byte) 0xDF, (byte) 0x08, (byte) 0x3F, (byte) 0x5D, (byte) 0x68, (byte) 0x1D, (byte) 0x3B, (byte) 0x89, (byte) 0x50, (byte) 0x69, (byte) 0xC6, (byte) 0xD9, (byte) 0x53, (byte) 0x65, (byte) 0x3C, (byte) 0x8E, (byte) 0x79, (byte) 0xA1, (byte) 0xCA, (byte) 0x94, (byte) 0xF7, (byte) 0x94, (byte) 0x06, (byte) 0xD1, (byte) 0x81, (byte) 0x41, (byte) 0xCE, (byte) 0x73, (byte) 0x95, (byte) 0x36, (byte) 0xab, (byte) 0xcd, (byte) 0xef }, decode("E208DF083F5D681D3B895069C6D953653C8E79A1CA94F79406D18141CE739536abcdef")); }