Java URL Encode encode(String s)

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

Description

URL encodes the specified string using the UTF-8 character encoding.

License

Open Source License

Declaration

public static String encode(String s) 

Method Source Code

//package com.java2s;

import java.io.UnsupportedEncodingException;

import java.net.URLEncoder;

public class Main {
    /**//from  w  w  w .  ja  v a2 s .  co m
     * URL encodes the specified string using the UTF-8 character encoding.
     */
    public static String encode(String s) {
        try {
            return (s != null) ? URLEncoder.encode(s, "UTF-8") : null;
        } catch (UnsupportedEncodingException uee) {
            throw new RuntimeException("UTF-8 is unknown in this Java.");
        }
    }
}

Related

  1. encode(String in)
  2. encode(String input)
  3. encode(String input)
  4. encode(String raw)
  5. encode(String s)
  6. encode(String s)
  7. encode(String s)
  8. encode(String s)
  9. encode(String s)