Tuesday 10 September 2013

How To Get System's IP Address and Host Name

1  public class MyIpAddress{  
2    public static void main(String[] args) {  
3      java.net.InetAddress ip = java.net.IpAddress.getLocalHost();  
4      System.out.println(ip);  
5      String hostName = ip.getHostName();  
6      System.out.println("Host name: " + hostName);  
7    }  
8  }  
And there you have it; the Computers ipaddress and the hostname.

No comments:

Post a Comment

Your suggestion counts...