Skip to content

Instantly share code, notes, and snippets.

@Ramasubramanian
Created October 3, 2011 15:51
Show Gist options
  • Save Ramasubramanian/1259427 to your computer and use it in GitHub Desktop.
Save Ramasubramanian/1259427 to your computer and use it in GitHub Desktop.
handler hash code
protected synchronized InetAddress getHostAddress(URL u) {
if (u.hostAddress != null)
return u.hostAddress;
String host = u.getHost();
if (host == null || host.equals("")) {
return null;
} else {
try {
u.hostAddress = InetAddress.getByName(host);
} catch (UnknownHostException ex) {
return null;
} catch (SecurityException se) {
return null;
}
}
return u.hostAddress;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment