梦幻之旅

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 阅读(286) 评论(0)  编辑  收藏 所属分类: Javajava Net

只有注册用户登录后才能发表评论。


网站导航: