Get fragment from a URI in Java

Description

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

Example


import java.net.URI;
//from  www  .java2s .c  o m
public class Main {

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

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

The code above generates the following result.





















Home »
  Java Tutorial »
    Network »




NetworkInterface
URI
URL
HTTP
HTTP Read
IP
Socket
UDP
URL Encode