UriUtils { private static void pctEncode(byte data, ByteArrayOutputStream bos) { bos.write('%'); char hex1 = Character.toUpperCase(Character.forDigit((data >> 4) & 0xF, 16)); char hex2 = Character.toUpperCase(Character.forDigit(data & 0xF, 16)); bos.write(hex1); bos.write(hex2); }  static boolean isEncoded(String value, Charset charset); static String encode(String value); static String encode(String value, Charset charset); static String encode(String value, boolean allowReservedCharacters); static String encode(String value, Charset charset, boolean allowReservedCharacters); static String decode(String value, Charset charset); static boolean isAbsolute(String uri); static String encodeInternal(String value,
                                      Charset charset,
                                      boolean allowReservedCharacters);  }
@Test public void pctEncode() { String queryParameterValue = "firstName=James;lastName=Bond;location=England&Britain?"; assertThat(UriUtils.encode(queryParameterValue, UTF_8)) .isEqualToIgnoringCase( "firstName%3DJames%3BlastName%3DBond%3Blocation%3DEngland%26Britain%3F"); }