URL: getRef() : URL « java.net « Java by API






URL: getRef()

 
/*
URL is http://www.java2s.com
authority is www.java2s.com
path is 
default port is 80
query is null
ref is null
 
 */
import java.io.IOException;
import java.net.URL;

public class MainClass {

  public static void main(String[] args) {
    try {
      URL url = new URL("http://www.java2s.com");
      System.out.println("URL is " + url.toString());
      System.out.println("authority is " + url.getAuthority());
      System.out.println("path is " + url.getPath());
      System.out.println("default port is " + url.getDefaultPort());
      System.out.println("query is " + url.getQuery());
      System.out.println("ref is " + url.getRef());
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

}

           
         
  








Related examples in the same category

1.new URL(String spec) throws MalformedURLException
2.URL: getAuthority()
3.URL: getDefaultPort()
4.URL.getPath()
5.URL: getQuery()
6.URL: openConnection()
7.URL: openStream()