Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 用于环回地址的Apache SubnetInfo_Java_Apache Commons_Cidr - Fatal编程技术网

Java 用于环回地址的Apache SubnetInfo

Java 用于环回地址的Apache SubnetInfo,java,apache-commons,cidr,Java,Apache Commons,Cidr,使用ApacheCommons网络库,为什么以下输出CIDR符号127.0.0.1/32的0地址?我早就预料到了,还是我误解了什么?地址127.0.0.1是否不在指定范围内 SubnetInfo rangeInfo = new SubnetUtils("127.0.0.1/32").getInfo(); System.out.println(rangeInfo.getAddressCount()); 我还没有测试它,但是似乎没有设置变量rangeInfo。如果这只是一个输入错误,那么这可能会为

使用ApacheCommons网络库,为什么以下输出CIDR符号127.0.0.1/32的0地址?我早就预料到了,还是我误解了什么?地址127.0.0.1是否不在指定范围内

SubnetInfo rangeInfo = new SubnetUtils("127.0.0.1/32").getInfo();
System.out.println(rangeInfo.getAddressCount());

我还没有测试它,但是似乎没有设置变量
rangeInfo
。如果这只是一个输入错误,那么这可能会为您提供正确的主机数量

SubnetInfo info = new SubnetUtils("127.0.0.1/32").getInfo();
info.setInclusiveHostCount(true);
System.out.println(info.getAddressCount());

是的,是一个打字错误。setInclusiveHostCount方法位于SubnetUtils类中,而不是SubnetInfo中,但在其他情况下,这是有效的,谢谢!