How to Get localhost IP Address in Java

Using the java.net.InetAddress, We can Get the localhost IP Address in Java. To get the localhost IP, We can Use the Code like import java.net.InetAddress; import java.net.UnknownHostException; public class IPAddress { public static void main(String[] args) { try { InetAddress ip = InetAddress.getLocalHost(); System.out.println(“IP is : ” + ip.getHostAddress()); } catch (UnknownHostException ex) { ex.printStackTrace(); … Read more