The java.net.InetAddress class represents an IP address. It provides the methods to work with IP and host name.
Get hostname from ip address in java
package com.w3schools; import java.net.InetAddress; public class NetworkTest { public static void main(String args[]){ try { InetAddress host = InetAddress.getByName("107.180.2.128"); System.out.println(host.getHostName()); } catch(Exception e) { e.printStackTrace(); } } }
Output
ip-107-180-2-128.ip.secureserver.net
Related topics
- How to create url object in java?
- How to create url object with properties in java?
- How to create url from file in java?
- How to read url properties in java?
- How to create relative url in java?
- How to compare two urls in java?
- How to read or get contents of a url in java?
- How to encode url in java?
- How to decode url in java?
- How to get ip address in java?
- How to get ip address of host in java?
- How to get hostname from ip address in java?
- How to get system hostname in java?
- How to get list of all ip addresses on network in java?