1 package org.jgroups.util; 2 3 import java.net.InetAddress ; 4 import java.net.NetworkInterface ; 5 import java.net.SocketException ; 6 import java.util.Enumeration ; 7 8 14 public class GetNetworkInterfaces { 15 16 public static void main(String [] args) throws SocketException { 17 Enumeration en=NetworkInterface.getNetworkInterfaces(); 18 while(en.hasMoreElements()) { 19 NetworkInterface i=(NetworkInterface )en.nextElement(); 20 System.out.println(i.getName() + ':'); 21 System.out.println(" \t" + i.getDisplayName()); 22 for(Enumeration en2=i.getInetAddresses(); en2.hasMoreElements();) { 23 InetAddress addr=(InetAddress )en2.nextElement(); 24 System.out.println(" \t" + addr + " (" + addr.getHostName() + ')'); 25 } 26 System.out.println("---------------------"); 27 } 28 } 29 30 } 31 | Popular Tags |