Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用以下代码,即找到我的子网掩码:
String subnetMask="/"+networkInterface.getInterfaceAddresses().get(0).getNetworkPrefixLength();
我的 IP 地址(从其他来源获得)是 192.168.0.130
但是上面的代码发现子网掩码是255.255.255.255,但我希望它是255.255.255.0。
我究竟做错了什么?
我不是那么喜欢java,但255.255.255.255绝不是一个糟糕的子网掩码;您很可能正在使用绑定到单个主机子网的接口,我相信这在您使用拨号和 ADSL 时是常态。
255.255.255.255
找出那个界面到底是什么以及它是如何设置的。这可能会给你一些线索(假设代码是正确的)。