package org.InetAddressDemo;
import java.net.InetAddress;
public class InetAddressDemo {
public static void main(String[] args) throws Exception{
InetAddress locAdd = null;
InetAddress remAdd = null;
locAdd = InetAddress.getLocalHost();
remAdd = InetAddress.getByName("www.hut.edu.cn");
System.out.println("本机IP地址:"+locAdd.getHostAddress());
System.out.println("hut的IP地址:"+remAdd.getHostAddress());
System.out.println("本机是否可达到:"+locAdd.isReachable(5000));
}
}Java网络编程(InetAddress),布布扣,bubuko.com
Java网络编程(InetAddress)
原文:http://blog.csdn.net/u012927417/article/details/38587761