com.marringtons.net.HTTP
Class URL
java.lang.Object
com.marringtons.net.HTTP.URL
- public class URL
- extends Object
This class contains static helper methods for preparing and comparing URLs.
- Author:
- Paul Marrington
|
Constructor Summary |
URL()
|
|
Method Summary |
static String |
getHost(String url)
Given a URL (with or without the http:// or other protocol), extract the
host name and port.
|
static boolean |
sameHosts(String url1,
String url2)
Given 2 URLs, compare and see if they come from the same host/port. |
URL
public URL()
getHost
public static String getHost(String url)
- Given a URL (with or without the http:// or other protocol), extract the
host name and port.
getHost("http://google.com/whatever.html").equals("google.com");
- Parameters:
url - to look at
- Returns:
- host portion of URL (including port if supplied)
sameHosts
public static boolean sameHosts(String url1,
String url2)
- Given 2 URLs, compare and see if they come from the same host/port. Note
that unlike the rest of the URL, the host name is case insensitive.
- Parameters:
url1 - First URL to compare.url2 - Second URL to compare.
- Returns:
- true if the 2 urls represent the same host/port (but possibly different paths).
Copyright © 2005 Paul Marrington http://library.marringtons.com