Here you can find the source of getEncodedUrl(String unEncodedUrl)
public static String getEncodedUrl(String unEncodedUrl)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; public class Main { private static final String ERR_ENCODE_STRING = "Could not encode url"; public static String getEncodedUrl(String unEncodedUrl) { try {//from w w w . ja va 2 s .c o m return URLEncoder.encode(unEncodedUrl, StandardCharsets.UTF_8.name()); } catch (UnsupportedEncodingException ex) { return ERR_ENCODE_STRING; } } }