URL getHost Example
URL class getHost example. This example shows you how to use getHost method.
URL class getHost example. public String getHost() Gets the host name of this URL, if applicable.
Here is the code
/*
* @ # GetHost.java
* A class repersenting use to getHost method
* of URL class in java.net package
* version 23 June 2008
* author Rose India
*/
import java.net.*;
public class GetHost {
public static void main(String args[]) throws Exception {
SocketAddress socketAddress = new InetSocketAddress("192.168.10.80", 9090);
Proxy proxy = new Proxy(Proxy.Type.HTTP, socketAddress);
URL url = new URL("http://google.com");
URLConnection uRLConnection = url.openConnection(proxy);
System.out.println(url.getHost());
}
} |
|