Here you can find the source of getNetworkInterfaces()
Parameter | Description |
---|---|
SocketException | If there's a socket error accessing theinterfaces. |
public static Collection<InetAddress> getNetworkInterfaces() throws SocketException
//package com.java2s; //License from project: Apache License import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.ArrayList; import java.util.Collection; import java.util.Enumeration; public class Main { /**//from w w w . java 2 s. co m * Utility method for accessing public interfaces. * * @return The {@link Collection} of public interfaces. * @throws SocketException If there's a socket error accessing the * interfaces. */ public static Collection<InetAddress> getNetworkInterfaces() throws SocketException { final Collection<InetAddress> addresses = new ArrayList<InetAddress>(); final Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); while (e.hasMoreElements()) { final NetworkInterface ni = e.nextElement(); final Enumeration<InetAddress> niAddresses = ni.getInetAddresses(); while (niAddresses.hasMoreElements()) { addresses.add(niAddresses.nextElement()); } } return addresses; } }