EscapeUtil { public static String urlEncode(String part) { try { return URLEncoder.encode(part, Charsets.UTF_8_NAME); } catch (UnsupportedEncodingException ignored) { return null; } }  static String urlEncode(String part); static String urlDecode(String part); static String escapeXml(String xml); static String unescapeXml(String xml); static String escapeHtml(String html); static String unescapeHtml(String html);  }
@Test public void urlEncode() { String input = "http: String result = EscapeUtil.urlEncode(input); assertThat(result).isEqualTo("http%3A%2F%2Flocahost%2F"); assertThat(EscapeUtil.urlDecode(result)).isEqualTo(input); input = "http: result = EscapeUtil.urlEncode(input); System.out.println(result); assertThat(EscapeUtil.urlDecode(result)).isEqualTo(input); }