This example shows you ip address of your network interface.
This example shows you ip address of your network interface.
GetIp.java
Output:
import java.net.*;
import java.util.*;
public class GetIp {
public static void main(String args[]) throws Exception {
Enumeration<NetworkInterface> nets =
NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets)) {
System.out.println("\nDisplay name : " + netint.getDisplayName());
Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
for (InetAddress inetAddress : Collections.list(inetAddresses)) {
System.out.println("InetAddress : " + inetAddress);
}
}
}
}
Display name : MS TCP Loopback interface
InetAddress : /127.0.0.1
Display name : Intel(R) PRO/100 VE Network Connection - Packet Scheduler Miniport
InetAddress : /192.168.10.208
Ads