Class Network


  • public final class Network
    extends java.lang.Object
    Network represents an IP network.
    • Constructor Summary

      Constructors 
      Constructor Description
      Network​(java.net.InetAddress ipAddress, int prefixLength)
      Construct a Network
    • Constructor Detail

      • Network

        public Network​(java.net.InetAddress ipAddress,
                       int prefixLength)
        Construct a Network
        Parameters:
        ipAddress - An IP address in the network. This does not have to be the first address in the network.
        prefixLength - The prefix length for the network.
    • Method Detail

      • getNetworkAddress

        public java.net.InetAddress getNetworkAddress()
        Returns:
        The first address in the network.
      • getPrefixLength

        public int getPrefixLength()
        Returns:
        The prefix length is the number of leading 1 bits in the subnet mask. Sometimes also known as netmask length.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        A string representation of the network in CIDR notation, e.g., 1.2.3.0/24 or 2001::/8.