ADVERTISEMENT
ADVERTISEMENT

Java program to get Host Name by IP Address

In this program we will provide Ip address of the google and program will print the hostname of the provided IP address.

Get Host Name by IP Address program in Java

//program to get host name by ip address
import java.net.*;

public class GetHostName {
  public static void main(String args[]) throws Exception {
    InetAddress inetAddress = InetAddress.getByName("8.8.8.8");
    System.out.println("Host Name: " + inetAddress.getHostName());
  }
}

Output:

    Host Name: google-public-dns-a.google.com

Core Java Example Programs »


ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.