code: public static String urlEncode(String s) {
  		if (s == null) {
  			return "";
  		}
  		String encoded = s;
  		try {
  			encoded = URLEncoder.encode(s, Config.DEFAULT_ENCODING);
  		} catch (UnsupportedEncodingException ex) {
  			logger.error(null, ex);
  		}
  		return encoded;
  	}
docs: URL-encodes a string.
  @param s a string
  @return the encoded string