夢幻之旅

          DEBUG - 天道酬勤

             :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            671 隨筆 :: 6 文章 :: 256 評論 :: 0 Trackbacks

           

          public static String[] getAllLocalHostIP()
              
          {
                  String[] ret 
          = null;
                  
          try
                  
          {
                      String hostName 
          = InetAddress.getLocalHost().getHostName();
                      
          if (hostName == null || hostName.length() < 1)
                      
          {
                          
          return ret;
                      }

                      InetAddress[] inetAddresses 
          = InetAddress.getAllByName(hostName);
                      
          if (inetAddresses == null || inetAddresses.length < 1)
                      
          {
                          
          return ret;
                      }

                      
                      ret 
          = new String[inetAddresses.length];
                      
          for (int i = 0; i < inetAddresses.length; i++)
                      
          {
                          ret[i] 
          = inetAddresses[i].getHostAddress();
                          
                      }

                  }

                  
          catch (Exception ex)
                  
          {
                      ex.printStackTrace();
                  }

                  
          return ret;
              }
          posted on 2010-12-01 08:44 HUIKK 閱讀(308) 評論(0)  編輯  收藏 所屬分類: Javajava Net
          主站蜘蛛池模板: 乳源| 屏边| 衡南县| 兴城市| 白沙| 阜康市| 中牟县| 峨山| 泰州市| 资中县| 丰镇市| 霞浦县| 茌平县| 紫金县| 蓝田县| 杂多县| 定兴县| 海兴县| 兰溪市| 克山县| 高雄市| 浪卡子县| 和政县| 南充市| 新丰县| 东乡县| 灵台县| 临邑县| 太谷县| 威宁| 龙南县| 新宾| 潢川县| 保亭| 兴和县| 桐城市| 峨眉山市| 镇沅| 永新县| 奉贤区| 上思县|