An IP address is either a 32-bit or 128-bit unsigned number used by the internet protocol. To store the host name resolutions, the class InetAddress is used.
Java Get IP Address
This section illustrates you how to obtain the IP Address of local host.
An IP address is either a 32-bit or 128-bit unsigned number used by the internet protocol. To store the host name resolutions, the class InetAddress is used. The method getLocalHost() returns the local host and the method getHostAddress() returns the IP address.
Here is the video tutorial of "How to get IP Address in Java?":
Here is the code of Java Get IP Address Example
import java.net.*;
|
Output will be displayed as: