Java URL Encode encode(String input)

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

Description

encode

License

Open Source License

Declaration

public static String encode(String input) 

Method Source Code


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

import java.io.*;
import java.net.*;

public class Main {
    private static String systemEncoding = System.getProperty("file.encoding");

    public static String encode(String input) {
        try {/*from  w ww.  j a v  a 2 s . co  m*/
            return URLEncoder.encode(input, systemEncoding).replace("+", "%20"); // FIX! usually we want UTF-8, which is not necessarily the system encoding.
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. encode(Object value)
  2. encode(Properties prop)
  3. encode(String _string, String _sEncoding)
  4. encode(String from, String to, String word)
  5. encode(String in)
  6. encode(String input)
  7. encode(String raw)
  8. encode(String s)
  9. encode(String s)