import java.net.*; import java.util.*; public class IpAddress { public static void main(String args[]) throws Exception { Enumeration nets = NetworkInterface.getNetworkInterfaces(); for (NetworkInterface netint : Collections.list(nets)) { System.out.println("\nDisplay name : " + netint.getDisplayName()); Enumeration inetAddresses = netint.getInetAddresses(); for (InetAddress inetAddress : Collections.list(inetAddresses)) { System.out.println("InetAddress : " + inetAddress); } } } }