How can I find out the current IP address for my machine?
The InetAddress has a static method called getLocalHost() which will return the current address of the local machine. We can then use the getHostAddress() method to get the IP address.
InetAddress local = InetAddress.getLocalHost();
// Print address
System.out.println (\"Local IP : \" + local.getHostAddress());