使用

欢马劈雪     最近更新时间:2020-01-02 10:19:05

560
查询URL的访问器方法
/*
n o w j a v a . c o m
*/


import java.io.IOException;

import java.net.URL;


public class Main {

  public static void main(String[] args) {

    URL url1 = null;

    URL url2 = null;

    try {

      url1 = new URL("http://nowjava.com/a/r/?q=javafx");


      String host = url1.getHost();

      String path = url1.getPath();

      String query = url1.getQuery();

      String protocol = url1.getProtocol();

      String authority = url1.getAuthority();

      String ref = url1.getRef();


      System.out.println("The URL " + url1.toString()

          + " parses to the following:\n");

      System.out.println("Host: " + host + "\n");
      /**
       from
      * N o w  J a v a  . c o m 
      **/

      System.out.println("Path: " + path + "\n");

      System.out.println("Query: " + query + "\n");

      System.out.println("Protocol: " + protocol + "\n");

      System.out.println("Authority: " + authority + "\n");

      System.out.println(
展开阅读全文