Module org.htmlunit

Class SubnetUtils

java.lang.Object
org.htmlunit.util.SubnetUtils

public class SubnetUtils extends Object
Performs subnet calculations given a network address and a subnet mask. Inspired by org.apache.commons.net.util.SubnetUtils.
Author:
Ronald Brill
See Also:
  • "https://www.faqs.org/rfcs/rfc1519.html"
  • Constructor Details

    • SubnetUtils

      public SubnetUtils(String address, String mask)
      Constructs an instance from a dotted-decimal address and a dotted-decimal mask.
      Parameters:
      address - an IP address, e.g. "192.168.0.1"
      mask - a dotted-decimal netmask, e.g. "255.255.0.0"
      Throws:
      IllegalArgumentException - if the address or mask is invalid
  • Method Details

    • isInRange

      public boolean isInRange(String address)
      Returns whether the given dotted-decimal IPv4 address is in the usable endpoint range for this subnet. The network and broadcast addresses are excluded.
      Parameters:
      address - a dot-delimited IPv4 address, e.g. "192.168.0.1"
      Returns:
      true if the address is in the usable range, false otherwise