Android URL Encode escapeURL(String link)

Here you can find the source of escapeURL(String link)

Description

escape URL

Declaration

public static String escapeURL(String link) 

Method Source Code

//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;
    }
}

Related

  1. encodeUrlParam(String s)
  2. weakUrlEncode(String url)
  3. encode(String s)
  4. getParams(Map params, String encode)
  5. encodeParameters(Map params)