Here you can find the source of escapeURL(String link)
public static String escapeURL(String link)
//package com.java2s; public class Main { public static String escapeURL(String link) { try {//from w w w.j av a 2 s. co m String path = link; path = java.net.URLEncoder.encode(path, "utf8"); path = path.replace("%3A", ":"); path = path.replace("%2F", "/"); path = path.replace("+", "%20"); path = path.replace("%23", "#"); path = path.replace("%3D", "="); return path; } catch (Exception e) { link = link.replaceAll("\\[", "%5B"); link = link.replaceAll("\\]", "%5D"); link = link.replaceAll("\\s", "%20"); } return link; } }