我正在编写一个需要IP地址的应用程序。我有一个域名,我想知道如何从它获得IP地址。例如,"www.girionjava.com“。我怎样才能通过Java编程获得这个网站的IP地址?谢谢。
发布于 2010-03-17 21:13:59
InetAddress giriAddress = java.net.InetAddress.getByName("www.girionjava.com");
然后,如果您想要将IP作为字符串
String address = giriAddress.getHostAddress();
发布于 2013-07-01 19:37:38
这应该很简单。
InetAddress[] machines = InetAddress.getAllByName("yahoo.com");
for(InetAddress address : machines){
System.out.println(address.getHostAddress());
}
发布于 2010-03-17 21:12:36
InetAddress.getByName("www.girionjava.com")
https://stackoverflow.com/questions/2462398
复制相似问题