package com.lzy.loc;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class IPTest {
public static void main(String[] args) throws UnknownHostException {
InetAddress addr = InetAddress.getLocalHost();
System.out.println(addr.getHostAddress());
System.out.println(addr.getHostName());
addr = InetAddress.getByName("www.baidu.com");
System.out.println(addr.getHostAddress());
System.out.println(addr.getHostName());
addr = InetAddress.getByName("10.12.32.194");
System.out.println(addr.getHostAddress());
System.out.println(addr.getHostName());
}
}