code: public static CidrInfo parseCIDR(String cidr) {
          requireNonNull(cidr);
          try {
              String[] parts = cidr.split("/");
              checkArgument(parts.length == 2);
  
              byte[] bytes = forString(parts[0]).getAddress();
              int maskBits = parseInt(parts[1]);
              checkArgument(maskBits >= 0 && maskBits <= bytes.length * 8);
  
              int remainingBits = maskBits;
              byte[] network = new byte[bytes.length];
              byte[] broadcast = new byte[bytes.length];
              for (int i = 0; i< bytes.length; i++) {
                  if (remainingBits >= 8) {
                      network[i] = bytes[i];
                      broadcast[i] = bytes[i];
                  } else if (remainingBits > 0) {
                      int byteMask = -1 << (8 - remainingBits);
                      network [i] = (byte) (bytes[i] & byteMask);
                      broadcast [i] = (byte) (bytes[i] | ~byteMask);
                  } else {
                      network[i] = 0;
                      broadcast[i] = (byte)0xff;
                  }
                  remainingBits -= 8;
              }
  
              return new CidrInfo(maskBits, bytesToInetAddress(network), bytesToInetAddress(broadcast));
  
          }catch(Exception ignored){}
  
          throw new IllegalArgumentException(format("Invalid CIDR string: %s", cidr));
      }
docs: Examines a CIDR {@code 192.168.0.0/16} or {@code 1234::/16} string representation and calculates the network and
  broadcast IP addresses for that subnet.  This accepts both IPv4 and IPv6 representations of a CIDR and will return
  the appropriate {@link InetAddress} classes for the provided value.
  
  <p>Note: This supports IPv6 "IPv4 mapped" addresses and will create a valid Inet6Address to account for them.