import java.net.InetAddress;
//=================================================
// File Name : InetAddress_demo
//------------------------------------------------------------------------------
// Author : Common
//主类
//Function : InetAddress_demo
public class InetAddress_demo {
public static void main(String[] args) throws Exception{
// TODO 自动生成的方法存根
InetAddress locAdd = null; //声明InetAddress对象
InetAddress remAdd = null; //声明InetAddress对象
locAdd = InetAddress.getLocalHost(); //得到本地的InetAddress对象
remAdd = InetAddress.getByName("www.baidu.com");
System.out.println("本机的IP地址:"+locAdd.getHostAddress());
System.out.println("远程的IP地址:"+remAdd.getHostAddress());
System.out.println("本机是否可达:"+locAdd.isReachable(5000));
}
}