Home » Core Java » net » InetAddress

InetAddress

java.net.Inet4Address Example

In this example we will discuss about Inet4Address and its usage. Inet4Address represents an Internet Protocol version 4 (IPv4) address. Inet4Address is a subclass of InetAddress class, which represents either a 32-bit or 128-bit unsigned number used as an IP, the lower-level protocol on which protocols like UDP and TCP are built. The Inet4Address class exists since JDK1.4.     ...

Read More »

How to get IP address in Java using InetAddress

An Internet Protocol address (IP address) is a numerical label assigned to each device (e.g., computer, printer) participating in a computer network that uses the Internet Protocol for communication. The designers of the Internet Protocol defined an IPv4 address as a 32-bit number. In this tutorial we are going to see how can you get the IP Address that is ...

Read More »

Get hostname from IP address

This is an example of how to get the host name of a remote host from its IP address. Doing hostname resolution from IP addresses implies that you should : Retrieve the Address object for the specified host that contains all address related information about the specific host Use the getHostName() and/or getCanonicalHostName() API methods to retrieve the hostname and/or ...

Read More »

Get IP address and hostname from local machine

In this example we shall show you how to retrieve the IP address and hostname from the local host. To get the IP address and hostname from the local machine one should perform the following steps : Retrieve the Address object for the local host. This object contains all address related information about the specific host Use the getAddress() API ...

Read More »

Get IP address from hostname

In this example we shall show you how to retrieve the IP address from the hostname of a specific host. To get the IP address using a hostname one should perform the following steps : Retrieve the Address object of the specific host. This object contains all address related information about the specific host Use the getAddress() API method to ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns