code: 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;
      }
docs: Convenience method to encode unencoded components of a URI.
  
  @param url      the string to be encoded by {@link URLCodec}
  @param encoding the character encoding to use
  @return         the encoded string