Encode colons(:) for URL in Java

Description

The following code shows how to encode colons(:) for URL.

Example


    /*  w ww.  j  ava 2 s.  com*/
import java.net.URLEncoder;

public class Main {

  public static void main(String[] args) throws Exception {
    System.out.println(URLEncoder.encode("A:B:C:D", "UTF-8"));
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Network »




NetworkInterface
URI
URL
HTTP
HTTP Read
IP
Socket
UDP
URL Encode