Perform Network Lookup with the InetAddress class
import java.net.InetAddress; publicclass Main { publicstaticvoid 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()); } }