code: public static String query(CharSequence s) throws IllegalArgumentException
     {
        try {
           return URLEncoder.encode(s.toString(), UTF8.name());
        }
        catch (UnsupportedEncodingException e) {
           throw new IllegalArgumentException(e);
        }
     }
docs: Encodes the given string using HTML form encoding as described in RFC 2396.
  
  @throws IllegalArgumentException when illegal URI syntax is attempted.