code: private static String encode(final String txt) {
          try {
              return URLEncoder.encode(
                  txt, Charset.defaultCharset().name()
              );
          } catch (final UnsupportedEncodingException ex) {
              throw new IllegalStateException(ex);
          }
      }
docs: Encode into URL.
  @param txt Text
  @return Encoded