在用客户端测试

大家好,这是我的第一个博客,请多多关照。

获取本机名

 1     public static String getServerName() {
 2         try {
 3             InetAddress addr = InetAddress.getLocalHost();
 4             String ip = addr.getHostAddress();
 5             String host = addr.getHostName().toString();// 获得本机名称
 6             return ip;
 7 
 8         } catch (Exception e) {
 9             return "未知";
10         }
11     }

 

 

 

posted @ 2013-10-31 19:07  把门一关  阅读(131)  评论(0)    收藏  举报