java.net.URLEncoder
java.lang.Object
None
None
JDK 1.0 or later
The URLEncoder class defines a single static method that converts a String to its URL-encoded form. More precisely, the String is converted to a MIME type called x-www-form-urlencoded.
This is the format used when posting forms on the Web. The algorithm leaves letters, numbers, and the dash (-), underscore ( _ ), period (.), and asterisk (*) characters unchanged. Space characters are converted to plus signs (+). All other characters are encoded with a percent sign (%) followed by the character code represented as a two-digit hexadecimal number. For example, consider the following string:
Jean-Louis Gassée
This string gets encoded as:
Jean-Louis+Gas%8ee
The point of the URLEncoder class is to provide a way to canonicalize a string into an extremely portable subset of ASCII that can be handled properly by computers around the world.
public class java.net.URLEncoder extends java.lang.Object {
  // Class Methods
  public static String encode(String s);
}
The string to encode.
A URL-encoded string.
This method returns the contents of the String in the x-www-form-urlencoded format.
| Method | Inherited From | Method | Inherited From | 
|---|---|---|---|
| clone() | Object | equals(Object) | Object | 
| finalize() | Object | getClass() | Object | 
| hashCode() | Object | notify() | Object | 
| notifyAll() | Object | toString() | Object | 
| wait() | Object | wait(long) | Object | 
| wait(long timeout, int nanos) | Object | 
String, URL