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
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Get IP Example View All Comments
Post your Comment