Java examples for Network:Network Address
Returns true when the given address is a local address.
//package com.java2s; import java.net.InetAddress; public class Main { /**//from w w w. j a v a 2 s .co m * Returns true when the given address is a local address. * @param addr address * @return true when the given address is a local address */ public static boolean hasLocalScope(InetAddress addr) { if (addr == null) throw new IllegalArgumentException("Must not be null!"); return (addr.isAnyLocalAddress() || addr.isLinkLocalAddress() || addr .isLoopbackAddress()); } }