Here you can find the source of encodeUri(String string)
public static String encodeUri(String string)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class Main { /**/* w w w . j av a 2 s . c om*/ * Encodes the given UTF-8 {@code string} so that it's safe for use * within an URI. */ public static String encodeUri(String string) { if (string == null) { return null; } try { return URLEncoder.encode(string, "UTF-8").replace("+", "%20"); } catch (UnsupportedEncodingException ex) { throw new IllegalStateException(ex); } } }