。net。;。net。;{=null;[]=null;(Stringargs[]){TestInetAddressaddress=newTestInetAddress();System。out。println("YourhostIPis:"+addr...全部
importjava。net。InetAddress;importjava。net。UnknownHostException;publicclassTestInetAddress{InetAddressmyIpAddress=null;InetAddress[]myServer=null;publicstaticvoidmain(Stringargs[]){TestInetAddressaddress=newTestInetAddress();System。
out。println("YourhostIPis:"+address。getLocalhostIP());Stringdomain="www。163。com";System。
out。println("Theserverdomainnameis:"+domain);InetAddress[]array=address。getServerIP(domain);intcount=0;for(inti=1;iSystem。
out。println("ip"+i+""+address。getServerIP(domain)[i-1]);count++;}System。out。println("IPaddresstotal:"+count);}/***获得localhost的IP地址*@return*/publicInetAddressgetLocalhostIP(){try{myIpAddress=InetAddress。
getLocalHost();}catch(UnknownHostExceptione){e。printStackTrace();}return(myIpAddress);}/***获得某域名的IP地址*@paramdomain域名*@return*/publicInetAddress[]getServerIP(Stringdomain){try{myServer=InetAddress。
getAllByName(domain);}catch(UnknownHostExceptione){e。printStackTrace();}return(myServer);}}编辑特别推荐:JAVA的整型与字符串相互转换Java中的System。