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());
}

written by objects \\ tags: , , ,


Leave a Reply

You must be logged in to post a comment.