Java InetAddress Check isIPv6(InetAddress addr)

Here you can find the source of isIPv6(InetAddress addr)

Description

Checks the IP protocol version (IPv4 or IPv6)

License

Open Source License

Parameter

Parameter Description
addr The address to check.

Return

True, if IPv6.

Declaration

public static boolean isIPv6(InetAddress addr) 

Method Source Code


//package com.java2s;
/*//from  w ww  .j av  a2  s .  c o  m
 * ------------------------------------------------------------------------------
 * Hermes FTP Server
 * Copyright (c) 2005-2014 Lars Behnke
 * ------------------------------------------------------------------------------
 * 
 * This file is part of Hermes FTP Server.
 * 
 * Hermes FTP Server is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * Hermes FTP Server is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Hermes FTP Server; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * ------------------------------------------------------------------------------
 */

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

public class Main {
    /**
     * Checks the IP protocol version (IPv4 or IPv6)
     * 
     * @param addr The address to check.
     * @return True, if IPv6.
     */
    public static boolean isIPv6(InetAddress addr) {
        return addr instanceof Inet6Address;
    }
}

Related

  1. isInet6Compatible(InetAddress address, Inet6Address inet6Address)
  2. isInRage(InetAddress check, InetAddress bcast, int netmask)
  3. isIpAddressInRange(InetAddress ipStart, InetAddress ipEnd, InetAddress ipToCheck)
  4. isIPLocal(final InetAddress adr)
  5. isIPv6(final InetAddress ip)
  6. isIPv6UniqueSiteLocal(InetAddress address)
  7. isLikelyBroadcast(InetAddress address)
  8. isLinkLocalIPv4Address(InetAddress add)
  9. isLinkLocalNetwork(InetAddress addr)