程序里面想实现这样的功能,输入域名之后,解析出对应ip,应该如何做?
解决方案 »
- jxl读excel文件出错,jxl.read.biff.BiffException: Unable to recognize OLE stream
- JEditorPane的setPage()和setText交替使用,无效的问题
- 问个基础型问题,关于"+"连接的,在线等
- 大家讨论一下为什么许多类都要重写equals()方法呢?
- 在Java中,如何以SSL方式连接FTP服务器?
- 初学线程请大家讲解下 (结贴迅速)
- 如何使JTable的表列固定大小
- 包的编译
- 升级了。首次散分。!!
- 请问有谁手上有IBM 的MQSeries Workflow的使用手册,或者别的Workflow产品的使用手册也行
- [求助]java实现word批量转pdf
- jdom中文帮助文档,另给一百分
Reply from 61.172.201.194: bytes=32 time=3ms TTL=248
Reply from 61.172.201.194: bytes=32 time=3ms TTL=248
Reply from 61.172.201.194: bytes=32 time=3ms TTL=248Ping statistics for 61.172.201.194:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 3ms, Maximum = 3ms, Average = 3ms
通过DNS服务器来查找
InetAddress myIPaddress = null; InetAddress myServer = null; public static void main(String args[]) {
NetTool mytool;
mytool = new NetTool();
System.out.println("Your host IP is: " + mytool.getMyIP());
System.out.println("The Server IP is :" + mytool.getServerIP()); } // 取得LOCALHOST的IP地址
public InetAddress getMyIP() {
try {
myIPaddress = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
}
return (myIPaddress);
} // 取得 www.abc.com 的IP地址
public InetAddress getServerIP() {
try {
myServer = InetAddress.getByName("www.abc.com");
} catch (UnknownHostException e) {
}
return (myServer);
}}
fdsafsdafdasfads
</html>
import java.net.*;
public class Kkkk
{
public static void main(String args[])throws Exception
{
InetAddress address=InetAddress.getByName("Claire");//Claire是我的计算机名
System.out.println(address);
System.out.println("-----");
InetAddress address1=InetAddress.getLocalHost();
System.out.println(address1);
InetAddress[] addresses=InetAddress.getAllByName("http://www.baidu.com");
for(InetAddress addr:addresses)
{
System.out.println(addr);
}
}
}运行结果为:
Claire/59.73.131.125
-----
Claire/59.73.131.125
http://www.baidu.com/221.238.203.46