public static boolean isIpAddress(String ipAddress){
  Matcher m1=validIPV4Pattern.matcher(ipAddress);
  if (m1.matches()) {
    return true;
  }
  Matcher m2=validIPV6Pattern.matcher(ipAddress);
  return m2.matches();
}

public static boolean isIpAddress ( String ipAddress ) { Matcher m1 = validIPV4Pattern . matcher ( ipAddress ) ; if ( m1 . matches ( ) ) { return true ; } Matcher m2 = validIPV6Pattern . matcher ( ipAddress ) ; return m2 . matches ( ) ; }
determine if the given string is a valid ipv4 or ipv6 address . this method uses pattern matching to see if the given string could be a valid ip address .
