Here you can find the source of uriEncoding(String plainString)
public static String uriEncoding(String plainString)
//package com.java2s; //License from project: Open Source License import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; public class Main { public static String uriEncoding(String plainString) { try {// w w w .j ava2 s.co m URL url = new URL(plainString); URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); return uri.toString(); } catch (URISyntaxException | MalformedURLException e) { System.out.println("Utilities.uriEncoding(String plainString)\nError trying to encode " + plainString); return null; } } }