Strings { public static StringBuilder hex(byte[] bytes) { StringBuilder hex = new StringBuilder(bytes.length + 2); for (byte b : bytes) { hex.append(String.format("%02x", b)); } return hex; }  static StringBuilder join(Object... objects); static StringBuilder hex(byte[] bytes);  }
@Test public void testHexString() { assertEquals("48656c6c6f21", Strings.hex("Hello!".getBytes()).toString()); assertEquals("0001", Strings.hex(new byte[]{0, 1}).toString()); }