Code example for InetAddress

Methods: isLinkLocalAddressisLoopbackAddressisSiteLocalAddress

0
        InetAddress best = bestSoFar;
        if (best == null) {
            // none selected so far, so this one is better. 
            best = current;
        } else { 
            if (current.isLoopbackAddress()) {
                // definitely not better than the previously selected address. 
            } else if (current.isLinkLocalAddress()) {
                // link local considered better than loopback 
                if (best.isLoopbackAddress()) {
                    best = current;
                } 
            } else if (current.isSiteLocalAddress()) {
                // site local considered better than link local (and loopback) 
                if (best.isLoopbackAddress() || best.isLinkLocalAddress()) {
                    best = current;
                } 
            } else { 
                // current is a global address, and therefore best (at least 
                // equally well)