Perform Network Lookup with the InetAddress class : IP Address « Network Protocol « Java
- Java
- Network Protocol
- IP Address
Perform Network Lookup with the InetAddress class
import java.net.InetAddress;
public class Main {
public static void main(String[] args) throws Exception{
InetAddress inetHost = InetAddress.getByName("www.google.com");
String hostName = inetHost.getHostName();
System.out.println(hostName);
System.out.println(inetHost.getHostAddress());
}
}
Related examples in the same category