Why is the 1st one returning null
, while the 2nd one is returning mail.yahoo.com
?
Isn\'t this weird? If not, what\'s the logic behind this
It's because of underscore in base uri. Just Remove underscore to check that out.It's working.
Like given below :
public static void main(String[] args) throws Exception {
java.net.URI uri = new java.net.URI("http://brokenarrow.huntingtonhelps.com");
String host = uri.getHost();
System.out.println("Host = [" + host + "].");
uri = new java.net.URI("http://mail.yahoo.com");
host = uri.getHost();
System.out.println("Host = [" + host + "].");
}