Convert IP Address to Hostname using Java

InetAddress class

package app; import java.net.InetAddress; import java.net.UnknownHostException; public class Main { public static void main(String[] args) throws UnknownHostException { String ip = "8.8.8.8"; InetAddress address = InetAddress.getByName(ip); String hostname = address.getHostName(); System.out.println(hostname); } }

Leave a Comment

Cancel reply

Your email address will not be published.