Oct
17
|
You can use the getNetworkPrefixLength() method in the InterfaceAddress class to get the size of the mask.
InetAddress localHost = Inet4Address.getLocalHost(); NetworkInterface networkInterface = NetworkInterface.getByInetAddress(localHost); for (InterfaceAddress address : networkInterface.getInterfaceAddresses()) { System.out.println(address.getNetworkPrefixLength()); }
Leave a Reply
You must be logged in to post a comment.