Here you can find the source of isLocalAddress(String host)
public static boolean isLocalAddress(String host)
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.net.UnknownHostException; public class Main { public static boolean isLocalAddress(String host) { try {//from www . j a v a2s . com InetAddress ia = InetAddress.getByName(host); if (ia.isAnyLocalAddress() || ia.isLoopbackAddress()) { return true; } return NetworkInterface.getByInetAddress(ia) != null; } catch (UnknownHostException | SocketException ex) { return false; } } }