Nov 12

Use the getHostName() method of the InetAddress class


InetAddress address = InetAddress.getByName(ipaddress);
String hostname = address.getHostName(); 

written by objects \\ tags: , ,

Oct 01

Use the getAddress() method in the InetAddress class.


InetAddress address = 
   InetAddress.getByName("192.168.1.1");
byte[] bytes = address.getAddress();
for (byte b : bytes)
{
    System.out.println(b & 0xFF);
} 

written by objects \\ tags: , ,

Sep 30

Use the getHostName() method of the InetAddress class


InetAddress address = InetAddress.getLocalHost();
String hostname = address.getHostName(); 

written by objects \\ tags: