获取本机ip

 1 import java.net.InetAddress;
 2 import java.net.UnknownHostException;
 3 
 4 
 5 public class HelloWrold {
 6 
 7     public static void main(String args[]) throws UnknownHostException
 8     {
 9            String ip = InetAddress.getLocalHost().getHostAddress();  
10            
11            System.out.println(ip);  
12     }
13 }
View Code

 

posted @ 2013-09-09 10:20  yufenghou  阅读(116)  评论(0)    收藏  举报