code: public static String urlquote(String text) {
          try {
              return URLEncoder.encode(text, "UTF-8").replace("+", "%20");
          } catch (UnsupportedEncodingException ex) {
              throw new RuntimeException(ex);
          }
      }
docs: Encodes text for inclusion in a URL query string. Should be equivalent to Django's urlquote function.
  @param text the text to encode
  @return the encoded text