Here you can find the source of isIPv6(final InetAddress ip)
public static boolean isIPv6(final InetAddress ip)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.net.Inet6Address; import java.net.InetAddress; public class Main { /** True if this InetAddress is a raw IPv6 in dotted quad notation. */ public static boolean isIPv6(final InetAddress ip) { return ip instanceof Inet6Address && ip.getHostName().equals(ip.getHostAddress()); }// ww w .j a v a 2 s .com }