code: public static String urlEncode(String s) {
          try {
              return URLEncoder.encode(s, StandardCharsets.UTF_8.name());
          } catch (UnsupportedEncodingException e) {
              throw new IllegalStateException("get a jdk that actually supports utf-8", e);
          }
      }
docs: Url encode a string and don't throw a checked exception. Uses UTF-8 as per RFC 3986.
  @param s a string
  @return url encoded string