public static boolean isLocalAddress(final InetAddress addr)
	{
		if (addr.isLoopbackAddress())
		{
			return true;
		}

		try
		{
			Enumeration<NetworkInterface> nics = NetworkInterface.getNetworkInterfaces();

			while (nics.hasMoreElements())
			{
				Enumeration<InetAddress> addrs = nics.nextElement().getInetAddresses();

				while (addrs.hasMoreElements())
				{
					if (addrs.nextElement().equals(addr))
					{
						return true; // Search successful
					}
				}
			}
		}
		catch (SocketException e)
		{
			log.debug(e.getMessage(), e);
		}

		log.debug("[FileHelper] {isLocalAddress} not local: " + addr.getHostAddress());

		// Search failed
		return false;
	}
public static boolean isLocalAddress ( final InetAddress addr ) { if ( addr . isLoopbackAddress ( ) ) { return true ; } try { Enumeration < NetworkInterface > nics = NetworkInterface . getNetworkInterfaces ( ) ; while ( nics . hasMoreElements ( ) ) { Enumeration < InetAddress > addrs = nics . nextElement ( ) . getInetAddresses ( ) ; while ( addrs . hasMoreElements ( ) ) { if ( addrs . nextElement ( ) . equals ( addr ) ) { return true ; } } } } catch ( SocketException e ) { log . debug ( e . getMessage ( ) , e ) ; } log . debug ( "[FileHelper] {isLocalAddress} not local: " + addr . getHostAddress ( ) ) ; return false ; }
Determines if a specified host or IP refers to the local machine

@param addr
String The host/IP

@return boolean True if the input points to the local machine, otherwise false Checks by enumerating the NetworkInterfaces
available to Java.