import java.net.InetAddress;
import java.net.UnknownHostException;
public class TestInetAddress {
InetAddress myIpAddress = null;
InetAddress[]myServer = null;
public static void main(String args[]){
TestInetAddress address = new TestInetAddress();
System.out.println(“Your host IP is:” + address.getLocalhostIP());
String domain = “www.163.com”;
System.out.println(“The server domain name is:” + domain);
InetAddress[]array = address.getServerIP(domain);
int count=0;
for(int i=1; i《array.length; i++){
System.out.println(“ip ”+ i +“ ”+ address.getServerIP(domain)[i-1]);
count++;
}
System.out.println(“IP address total:”+count);
}
/**
* 获得localhost 的IP地址
* @return
*/
public InetAddress getLocalhostIP(){
try {
myIpAddress = InetAddress.getLocalHost();
更多免费相关学习经验请访问:Tore_m_1206686_21115_1_1.html”>http://www.shangxueba.com/sTore_m_1206686_21115_1_1.html
人爱美,不仅需要服饰居室之美,还需要心灵品德之美。