ZsyncUtil { public static String toHexString(ByteBuffer buffer) { final StringBuilder r = new StringBuilder(buffer.remaining() * 2); while (buffer.hasRemaining()) { final byte b = buffer.get(); r.append(HEX_CODE[(b >> 4) & 0xF]); r.append(HEX_CODE[(b & 0xF)]); } return r.toString(); }  static String toHexString(ByteBuffer buffer); static int computeRsum(byte[] block); static int toInt(short x, short y); static long toLong(int x, int y); static short unsigned(byte b); static String computeSha1(ReadableByteChannel channel); static MessageDigest newMD4(); static MessageDigest newSHA1(); static Path getPath(URI uri);  }
@Test public void testToHexString() { assertEquals("01fe", ZsyncUtil.toHexString(ByteBuffer.wrap(new byte[] {1, (byte) -2}))); }
@Test public void testToHexStringEmtpy() { assertEquals("", ZsyncUtil.toHexString(ByteBuffer.allocate(0))); }