code: public static String urlEncode(String url) {
          try {
              return URLEncoder.encode(url, Constant.DEFAULT_ENCODING);
          } catch (UnsupportedEncodingException e) {
              return url;
          }
      }
docs: url encode