public static String encode ( String url , String encoding ) { String encodedURL = null ; try { encodedURL = URLCodec . encode ( url , encoding ) ; } catch ( java . io . UnsupportedEncodingException e ) { // try utf-8 as a default encoding try { encodedURL = URLCodec . encode ( url , DEFAULT_ENCODING ) ; } catch ( java . io . UnsupportedEncodingException ignore ) { } } return encodedURL ; }
Convenience method to encode unencoded components of a URI .