package com.bdqn.demo20180526;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.net.UnknownHostException;
/**
* 第5章网络编程 2.编写一个程序,查找指定域名为www.taobao.com的所有可能的ip地址。
*
* @author 123123
*
*/
public class TaobaoTest {
/**
* 淘宝主服务器地址
*
* @param taoBao
* 网址
*/
public static void getByName(String taoBao) {
* 第5章网络编程 2.编写一个程序,查找指定域名为www.taobao.com的所有可能的ip地址。
*
* @author 123123
*
*/
public class TaobaoTest {
/**
* 淘宝主服务器地址
*
* @param taoBao
* 网址
*/
public static void getByName(String taoBao) {
try {
InetAddress address = InetAddress.getByName(taoBao);
System.out.println(address);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
InetAddress address = InetAddress.getByName(taoBao);
System.out.println(address);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* 淘宝的所有服务器地址
*
* @param taoBao
*/
public static void getAllByName(String taoBao) {
try {
InetAddress[] addresses = InetAddress.getAllByName(taoBao);
String[] ip = new String[addresses.length];
for (int i = 0; i < addresses.length; i++) {
ip[i] = addresses[i].getHostAddress();
System.out.println(ip[i]);
}
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
* 淘宝的所有服务器地址
*
* @param taoBao
*/
public static void getAllByName(String taoBao) {
try {
InetAddress[] addresses = InetAddress.getAllByName(taoBao);
String[] ip = new String[addresses.length];
for (int i = 0; i < addresses.length; i++) {
ip[i] = addresses[i].getHostAddress();
System.out.println(ip[i]);
}
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
System.out.println("------淘宝的主服务器地址------");
String taoBao &#
System.out.println("------淘宝的主服务器地址------");
String taoBao &#