Get the path from a URI in Java

Description

The following code shows how to get the path from a URI.

Example


import java.net.URI;
/*from   www.j  a  v a  2  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 path is " + u.getPath());    
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Network »




NetworkInterface
URI
URL
HTTP
HTTP Read
IP
Socket
UDP
URL Encode