Here you can find the source of encodeUri(String uri)
public static String encodeUri(String uri)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { public static String encodeUri(String uri) { int quoIndex = uri.indexOf("?"); if (quoIndex < 0 || quoIndex == uri.length()) { return uri; }/*from w w w. jav a 2s. c o m*/ String url = uri.substring(0, quoIndex); String param = uri.substring(quoIndex + 1); String encodedUri = uri; try { encodedUri = url + "?" + URLEncoder.encode(param, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return encodedUri; } }