/** * Acquires the first {@link InetAddress} (of the machine on which this code is executing) * that matches the specified {@link Predicate}. * * @param predicate the {@link InetAddress} {@link Predicate} * * @return an {@link InetAddress} or <code>null</code> if no matching {@link InetAddress} * * @throws SocketException when an {@link InetAddress} is not available */ public static InetAddress getInetAddress(Predicate<? super InetAddress> predicate) throws SocketException { for (NetworkInterface networkInterface : getNetworkInterfaces(Predicates.<NetworkInterface>always())) { for (Enumeration addresses = networkInterface.getInetAddresses(); addresses.hasMoreElements(); ) { InetAddress address = (InetAddress) addresses.nextElement(); if (predicate.test(address)) { return address; } } } return null; }
for (NetworkInterface networkInterface : getNetworkInterfaces(Predicates.<NetworkInterface>always()))
/** * Acquires the first {@link InetAddress} (of the machine on which this code is executing) * that matches the specified {@link Predicate}. * * @param predicate the {@link InetAddress} {@link Predicate} * * @return an {@link InetAddress} or <code>null</code> if no matching {@link InetAddress} * * @throws SocketException when an {@link InetAddress} is not available */ public static InetAddress getInetAddress(Predicate<? super InetAddress> predicate) throws SocketException { for (NetworkInterface networkInterface : getNetworkInterfaces(Predicates.<NetworkInterface>always())) { for (Enumeration addresses = networkInterface.getInetAddresses(); addresses.hasMoreElements(); ) { InetAddress address = (InetAddress) addresses.nextElement(); if (predicate.test(address)) { return address; } } } return null; }
for (NetworkInterface networkInterface : getNetworkInterfaces(Predicates.<NetworkInterface>always()))
for (NetworkInterface networkInterface : getNetworkInterfaces(Predicates.<NetworkInterface>always()))
for (NetworkInterface networkInterface : getNetworkInterfaces(Predicates.<NetworkInterface>always()))