程序里面想实现这样的功能,输入域名之后,解析出对应ip,应该如何做?
解决方案 »
- 难道这个是多态?
- 离线消息是不是需要保存在专门的表里?
- 如何列出某个目录下的所有文件
- 怎么设置这样一个快捷键?请求帮忙啊!
- java3d 与 jME 哪个更优越呢,他们2兼容吗
- 判断两个无序数组相等问题
- 用JBuilder2006如何将工程或者类做成.jar文件啊?
- 100分求几个下载swing或者swt控件的网站。
- classes111.jar是什么数据库的驱动,可以用在jdbc-sql server2000中吗?在线等待
- 如何在jdk中添加/设置cocoon2.1的类库,可以免去在classpath中的设置,同时可以使得cocoon正常运行?在线等待
- [求助]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