Java URL Encode encode(String string)

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

Description

encode

License

Open Source License

Declaration

private static String encode(String string) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class Main {
    private static String encode(String string) {
        try {//from   ww w.ja va  2 s  . c om
            return URLEncoder.encode(string, "UTF-8").replaceAll("\\+",
                    "%20");
        } catch (UnsupportedEncodingException e) {
            return null;
        }
    }
}

Related

  1. encode(String s, String encoding)
  2. encode(String source)
  3. encode(String src, String srcCode, String destCode)
  4. encode(String str)
  5. encode(String str)
  6. encode(String strInput)
  7. encode(String text)
  8. encode(String toBeEncoded, String charSet, String defaultReturnValue)
  9. encode(String value)