Java——IP和InetAddress

Java——IP和InetAddress

Java——IP和InetAddress

Java——IP和InetAddress

Java——IP和InetAddress

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));
} }
上一篇:MongoDB在Windows下安装、Shell客户端的使用、Bson扩充的数据类型、MongoVUE可视化工具安装和简单使用、Robomongo可视化工具(2)


下一篇:转:如何让LoadRunner实现多个场景运行?