public static boolean isValidLocalIP ( InetAddress ip ) throws SocketException { String ipStr = ip . getHostAddress ( ) ; Iterator ips = getAllIPAddresses ( ) . iterator ( ) ; while ( ips . hasNext ( ) ) { InetAddress ip2 = ( InetAddress ) ips . next ( ) ; if ( ip2 . getHostAddress ( ) . equals ( ipStr ) ) { return true ; } } return false ; }
Decides whether an IP is local or not