Getting the IP Address of a Hostname
try {
InetAddress addr = InetAddress.getByName("javaalmanac.com");
byte[] ipAddr = addr.getAddress();
// Convert to dot representation
String ipAddrStr = "";
for (int i=0; i<ipAddr.length; i++) {
if (i > 0) {
ipAddrStr += ".";
}
ipAddrStr += ipAddr[i]&0xFF;
}
} catch (UnknownHostException e) {
}
good code.. but what
isthe post of the code and prefix
Very very use full for me, so many thanks
Why go through the hassle of formatting the byte array, when "getHostAddress()" gives you a formatted string?