Results 1 to 1 of 1
Thread: IP to HostName
-
IP to HostName
Each host name has an IP assigned to it. Sometimes it is useful to have a routine for converting an IP to its hostname. Following routine does exactly that:
Java Code:String ipAddress = "127.0.0.1"; InetAddress inetAddress = null; try { inetAddress = InetAddress.getByName(ipAddress); } catch (UnknownHostException e) { e.printStackTrace(); } System.out.println("InetAddress object has this: " + ipAddress.toString()); System.out.println("Host name :" + inetAddress.getHostName()); System.out.println("canonical host name: " + inetAddress.getCanonicalHostName());
Similar Threads
-
org.apache.commons.mail.EmailException: Cannot find valid hostname
By Ed in forum Advanced JavaReplies: 3Last Post: 07-25-2011, 03:19 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks