EncodingUtils { public static String encode(final String str) { String s = ""; try { s = URLEncoder.encode(str, DEFAULT_CHARSET); } catch (UnsupportedEncodingException e) { } return s; } private  EncodingUtils(); static String encode(final String str); static String encodeUrl(final String url); static String encodeUri(final String uri); static String encodeFilename(final String filename, final String userAgent);  }
@Test public void testEncode() throws Exception { assertEquals("%2F", EncodingUtils.encode("/")); assertEquals("%2B", EncodingUtils.encode("+")); assertEquals("%23", EncodingUtils.encode("#")); assertEquals("+", EncodingUtils.encode(" ")); }