Java InetAddress Check isAny(InetAddress ip)

Here you can find the source of isAny(InetAddress ip)

Description

Returns true if the passed InetAddress contains all zero

License

Open Source License

Parameter

Parameter Description
ip the IP address to test

Return

true if the address is all zero

Declaration

public static boolean isAny(InetAddress ip) 

Method Source Code

//package com.java2s;
/*//w  ww.j a v a2  s. co m
 * Copyright (c) 2013-2014 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

import java.net.InetAddress;

public class Main {
    /**
     * Returns true if the passed InetAddress contains all zero
     *
     * @param ip the IP address to test
     * @return true if the address is all zero
     */
    public static boolean isAny(InetAddress ip) {
        for (byte b : ip.getAddress()) {
            if (b != 0) {
                return false;
            }
        }
        return true;
    }
}

Related

  1. createRandomSocketAddressList( InetAddress bindAddress, int preferredPort, int minPort, int maxPort)
  2. formatAddresses( List addresses)
  3. getInetAddressList(NetworkInterface netInterface)
  4. is6to4(InetAddress addr)
  5. isAddressReachable(InetAddress address)
  6. isBroadcastAddress(InetAddress address)
  7. IsBusy(final InetAddress remote, int port)
  8. isClassicAddress(InetAddress address)
  9. isCommonSubnet(InetAddress address1, InetAddress address2)