检查一个子网是否在另一个子网的范围内,这对于将子网划分为块很有用
/** * Copyright 2012 InCNTRE, This file is released under Apache 2.0 license except for component libraries under different licenses http://www.apache.org/licenses/LICENSE-2.0 */ /* 来自 *n o w j a v a . c o m*/ //package com.nowjava; public class Main { /** * check if one subnet is in range of the other, useful , for dividing subnet into chunks * @see generateIpRules * @param ip1 * @param subnet1 * @param ip2 * @param subnet2 * @return boolean of whether IP in range or not */ public static boolean checkIfInRange(int ip1, int subnet1, int ip2, int subnet2) { if (subnet2 < subnet1) return false; String ip1String = Integer.toHexString(ip1); String ip2String = Integer.toHexString(ip2); /* *来 自 n o w j a v a . c o m - 时 代 Java */