Here you can find the source of getAllInetAddress(final String interfaceName)
public static List<InetAddress> getAllInetAddress(final String interfaceName) 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.Arrays; import java.util.Enumeration; import java.util.List; import java.util.Vector; public class Main { public static List<InetAddress> getAllInetAddress() throws SocketException { return getAllInetAddress(null); }//from w w w. j a v a 2s .co m public static List<InetAddress> getAllInetAddress(final String interfaceName) throws SocketException { final List<InetAddress> ret = new ArrayList<>(); final Enumeration<NetworkInterface> netInterfaces = getInterfaces(interfaceName); while (netInterfaces.hasMoreElements()) { final NetworkInterface networkInterface = netInterfaces.nextElement(); for (final Enumeration<InetAddress> loopInetAddress = networkInterface .getInetAddresses(); loopInetAddress.hasMoreElements();) { final InetAddress tempInetAddress = loopInetAddress.nextElement(); ret.add(tempInetAddress); } } return ret; } static Enumeration<NetworkInterface> getInterfaces(final String interfaceName) throws SocketException { return interfaceName != null ? new Vector<NetworkInterface>(Arrays.asList(NetworkInterface.getByName(interfaceName))).elements() : NetworkInterface.getNetworkInterfaces(); } }