Getting the IP Address and Hostname of the Local Machine

try { InetAddress addr = InetAddress.getLocalHost(); // Get IP Address byte[] ipAddr = addr.getAddress(); // Get hostname String hostname = addr.getHostName(); } catch (UnknownHostException e) { }

Comments

26 Jan 2010 - 12:45pm by vgarmash (not verified)

Good example. Thank you!

28 Feb 2010 - 12:50am by Alex (not verified)

Gracias

9 Mar 2010 - 12:58pm by Anonymous (not verified)

Gracias!!!

12 Mar 2010 - 1:58pm by Anonymous (not verified)

danke szun!

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.