// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import java.net.NetworkInterface;
import java.net.InetAddress;
import java.util.Enumeration;

public class NI15 {
    public static void main(String[] args) throws Exception {
        Enumeration e = NetworkInterface.getNetworkInterfaces();
        while(e.hasMoreElements()) {
            NetworkInterface ni = (NetworkInterface)e.nextElement();
            System.out.println("Net interface: " + ni.getName());
            Enumeration e2 = ni.getInetAddresses();
            while (e2.hasMoreElements()){
                InetAddress ip = (InetAddress)e2.nextElement();
                System.out.println("IP address: " + ip.getHostAddress());
            }
        }
    }
}
