Java InetAddress Check isValidIpAddress(InetAddress ip)

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

Description

Determine if IP address is valid for BUG to use for event notification.

License

Open Source License

Parameter

Parameter Description
ip a parameter

Declaration

private static boolean isValidIpAddress(InetAddress ip) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2006, 2007 Bug Labs, Inc..
 * 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.buglabs.net/legal/epl_license.html
 *******************************************************************************/

import java.net.Inet6Address;
import java.net.InetAddress;

public class Main {
    /**/*ww w.ja v a 2  s  . c o m*/
     * Determine if IP address is valid for BUG to use for event notification.
     * 
     * @param ip
     * @return
     */
    private static boolean isValidIpAddress(InetAddress ip) {
        if (ip instanceof Inet6Address) {
            return false;
        }

        // loopback
        if (ip.getAddress()[0] == 127) {
            return false;
        }

        return true;
    }
}

Related

  1. isValidCiscoWildcard(InetAddress wildcard)
  2. isValidInetAddress(String address)
  3. isValidInetAddress(String ip)
  4. isValidInetAddress(String IP)
  5. isValidIntranetAddress(InetAddress address)
  6. isWindowsAutoConfiguredIPv4Address(InetAddress add)
  7. sortAddresses(List addressList)