code: public static String encodeUrl(String stringToEncode) {
          try {
              return URLEncoder.encode(stringToEncode, "UTF-8");
          } catch (UnsupportedEncodingException e1) {
              throw new RuntimeException(e1);
          }
      }
docs: URL-Encodes a given string using UTF-8 (some web pages have problems with UTF-8 and umlauts, consider
  {@link #encodeUrlIso(String)} also). No UnsupportedEncodingException to handle as it is dealt with in this
  method.