Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.net

Class URLEncoder

java.lang.Object
|
+--java.net.URLEncoder


public class URLEncoder

extends Object

This utility class contains static methods that converts a string into a fully encoded URL string in x-www-form-urlencoded format. This format replaces certain disallowed characters with encoded equivalents. All upper case and lower case letters in the US alphabet remain as is, the space character (' ') is replaced with '+' sign, and all other characters are converted to a "%XX" format where XX is the hexadecimal representation of that character in a certain encoding (by default "UTF-8").

This method is very useful for encoding strings to be sent to CGI scripts

Authors:

Method Summary

static java.lang.Stringencode(java.lang.String s)

This method translates the passed in string into x-www-form-urlencoded format using the standard "UTF-8" character encoding to hex-encode the unsafe characters.
static java.lang.Stringencode(java.lang.String s, java.lang.String encoding)

This method translates the passed in string into x-www-form-urlencoded format using the character encoding to hex-encode the unsafe characters.

Method Details

encode

public static String encode(java.lang.String s)

This method translates the passed in string into x-www-form-urlencoded format using the standard "UTF-8" character encoding to hex-encode the unsafe characters.

Parameters:

Returns:


encode

public static String encode(java.lang.String s, java.lang.String encoding)

This method translates the passed in string into x-www-form-urlencoded format using the character encoding to hex-encode the unsafe characters.

Since:Parameters:

Returns:

Throws: