Here you can find the source of getAddressInfoFindAll(Function
private static List<String> getAddressInfoFindAll(Function<InetAddress, String> convertValue, Predicate<String> doBreak) throws SocketException
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.function.Function; import java.util.function.Predicate; public class Main { private static List<String> getAddressInfoFindAll(Function<InetAddress, String> convertValue, Predicate<String> doBreak) throws SocketException { Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); List<String> findAll = new ArrayList<>(); END: while (networkInterfaces.hasMoreElements()) { NetworkInterface nextElement = networkInterfaces.nextElement(); if (nextElement.isVirtual()) continue; if (nextElement.isLoopback()) continue; if (!nextElement.isUp()) continue; Enumeration<InetAddress> inetAddresses = nextElement.getInetAddresses(); while (inetAddresses.hasMoreElements()) { InetAddress netAddress = inetAddresses.nextElement(); if (!netAddress.isLoopbackAddress() && !netAddress.isLinkLocalAddress() && netAddress.isSiteLocalAddress()) { String hostAddress = netAddress.getHostAddress(); if (hostAddress.startsWith("192.168")) continue; String val = convertValue.apply(netAddress); findAll.add(val); if (doBreak.test(val)) break END; }//from w w w .ja v a 2s . c o m } } return findAll; } }