Android examples for Network:Network Operation
Calculates the network mask value from the address
//package com.java2s; import java.net.InetAddress; public class Main { /**// w w w. j a va 2 s . co m * Calculates the network mask value from the address * * @param address * the network mask * @return */ public static int networkMaskFromInetAddress(InetAddress address) { byte[] addrs = address.getAddress(); int result = 0; int i = 24; for (byte value : addrs) { result += value << i; i -= 8; } return result; } }