Android URL Encode encode(String s)

Here you can find the source of encode(String s)

Description

encode

Declaration

public static String encode(String s) 

Method Source Code

//package com.java2s;

import java.io.*;

import java.net.URLEncoder;

public class Main {

    public static String encode(String s) {
        if (s == null) {
            return "";
        }/*from   w w w . jav a  2 s.c o m*/
        try {
            return URLEncoder.encode(s, "UTF-8").replace("+", "%20")
                    .replace("*", "%2A").replace("%7E", "~")
                    .replace("#", "%23");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }
}

Related

  1. encodeUrl(Bundle parameters)
  2. encodeUriSegment(String segment)
  3. encodeUrl(Bundle parameters)
  4. encodeUrlParam(String s)
  5. weakUrlEncode(String url)
  6. getParams(Map params, String encode)
  7. encodeParameters(Map params)
  8. escapeURL(String link)