Below is the Java code which gives all the IP address of the current machine.
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
public class CommonUtils {
public static void main(String[] args) {
InetAddress inetAddress = InetAddress.getLocalHost();
System.out.println("IP Address:- " + inetAddress.getHostAddress());
System.out.println("Host Name:- " + inetAddress.getHostName());
}
}