Sample code for 30+ languages & platforms
Java

URL Encoding and Decoding

Demonstrates URL encoding/decoding using the HTTP convenience methods.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.Http;

public class ChilkatExample {

    public static void main(String[] args) {
        Http http = new Http();

        String s = "Hello World! 100% sure.";

        String encoded = http.urlEncode(s);
        System.out.println("URL encoded: " + encoded);

        // Space → %20
        // ! → %21
        // % → %25

        String decoded = http.urlDecode(encoded);
        System.out.println("URL decoded: " + decoded);

        // Output:

        // URL encoded: Hello%20World%21%20100%25%20sure.
        // URL decoded: Hello World! 100% sure.
    }
}