返回没有本地作用域(环回等)的所有地址的集合。
//package com.nowjava; import java.net.InetAddress; import java.util.ArrayList;//nowjava - 时 代 Java import java.util.Collection; public class Main { /** * Returns a collection of all addresses which do not have a local scope (loopbacks etc). * @param addresses all addresse * @return the addresses which are not loopbacks/linklocal */ public static Collection<InetAddress> getExternalAddresses( InetAddress[] addresses) { ArrayList<InetAddress> result = new ArrayList<InetAddress>(); for (InetAddress addr : addresses) { if (addr.isAnyLocalAddress() || addr.isLinkLocalAddress() || addr.isLoopbac