Java URL Value Check checkUrl(URL url, URL baseUrl)

Here you can find the source of checkUrl(URL url, URL baseUrl)

Description

check Url

License

Apache License

Declaration

static void checkUrl(URL url, URL baseUrl) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.net.URL;

public class Main {
    static void checkUrl(URL url, URL baseUrl) {
        // Is there a better test to use here?

        if (baseUrl.getHost() == null) {
            throw new RuntimeException("base URL is null");
        }//from   w w  w. jav  a2 s .  c o  m

        if (!baseUrl.getHost().equalsIgnoreCase(url.getHost())) {
            throw new RuntimeException("Domain of URL " + url + " doesn't match base URL " + baseUrl);
        }
    }
}

Related

  1. checkUrl(final String link)
  2. checkURL(String _url)
  3. checkUrl(String inputUrlString)
  4. checkUrl(String url, int timeout)
  5. checkURL(URL check)
  6. checkURLAvailable(String targetUrl)
  7. checkUrlImage(final String url)
  8. checkURLStatus(String pURL)
  9. checkURLValidProtocol(URL url)