Get Scheme from a URI in Java

Description

The following code shows how to get Scheme from a URI.

Example


import java.net.URI;
/*from  w w w . j  a  v a2 s  .  co m*/
public class Main {

  public static void main(String args[]) throws Exception {

    URI u = new URI("http://www.java2s.com");
    System.out.println("The scheme is " + u.getScheme());
    
  }

}

The code above generates the following result.





















Home »
  Java Tutorial »
    Network »




NetworkInterface
URI
URL
HTTP
HTTP Read
IP
Socket
UDP
URL Encode