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());
}
}
Jkoder.com Tutorials, Tips and interview questions for Java, J2EE, Android, Spring, Hibernate, Javascript and other languages for software developers